What are the differences between the Template Template helpers and the Handlebars helpers?

Iโ€™m trying to understand the differences, pros and cons of using Meteor template helpers versus using Handlebars template helpers.

For instance:

Template.users_insert.is_state_selected = function(code){}; 

vs

 Handlebars.registerHelper('is_state_selected', function(code){}); 

They seem to do the same, except that the Handelbars helper has a wider reach for us than Temple.my_template.helper_function .

My big problems are not only the differences and the pros and cons, but also the side effects that may be caused by others.

+4
source share
2 answers

Here is how I distinguish between these two mechanisms, there is no guarantee of correctness;)

Meteor template methods are used to bind data, so they have a local scope. Each template needs a subset of the application data, possibly presented in various forms. And this subset is defined using template methods.

Handlebars is the template structure itself, so helpers control how your application will present the data it receives from the Meteor data layer. You may need special types of enumeration, you need a way to "match" data values โ€‹โ€‹with paths, etc. But you only work with data provided by the "data layer" and do not extend it.

+1
source

One thing is missing here.

Hand tool assistants registered with

 Handlebars.registerHelper('helper_name', function(){}); 

available for the whole project.

in Meteor

Template.my_template.helpers({});

or

Template.my_template.my_helper = function(){};

available only for the current template: for example. my_template

+3
source

All Articles