Reputation: 63647
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;
}
});
Upvotes: 4
Views: 1674
Reputation: 7680
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() { /*...*/ }
});
Upvotes: 3