Reputation: 18825
In Meteor, if the below is my HTML,
<template name="myTemplate">
The value is {{value}}
</template>
I can define the value in two ways
Template.myTemplate.helpers
value: ->
'insideHelper1'
Template.myTemplate.value =
'outsideHelper1'
The first way is using helpers as documented here (http://docs.meteor.com/#template_helpers) whereas the second way is using the Live Template examples as defined here (http://docs.meteor.com/#livehtmltemplates)
Just wondering, what is the difference between the two and when should I use one over the other?
Upvotes: 1
Views: 139
Reputation: 75955
They're exactly the same.
If you use .helpers
, it actually just adds it to Template.
.
It depends on your coding style. You may prefer to use .helpers
since it makes cleaner code if you have many helpers on the same template.
One small technically way they're different is Template.helpers
adds the helpers to your Meteor app when your Meteor app starts up, whereas using the Template.helpername
adds it before. So if you need to overwrite any helpers, you could use the .helpers
method. The one that runs last will have the active helper.
Upvotes: 3