Difference between Template Helper and Template Variable in Meteor.js

handlebars.js, javascript, meteor, node.js

Solution

Nothing, as explained in this section of the docs. The only difference that the second way allows you to use more keywords. For example, you can't do this:

Template.foo.events = function() { /*...*/ };

But you can do this:

Template.foo.helpers({
    "events": function() { /*...*/ }
});

Problem

What is the difference between using a Template Helper and a Template Variable (incorrect term?)? When do you decide which to use? In the example below, both `Template.apple.price` function and the `quantity` function in `Template.apple.helpers` appear to do the same thing. ``` <template name="apple"> {{price}} {{quantity}} </template> Template.apple.price = function() { return 20; } Template.apple.helpers({ 'quantity': function() { return 100; } }); ```

Original source