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;
}
});
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() { /*...*/ }
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.