Reputation: 701
Is there a way to use something similar in Meteor to this
{{#if $.Session.equals 'sessionName' value1}}
<p> value1 </p>
{{/if}}
{{#if $.Session.equals 'sessionName' value2}}
<p> value2 </p>
{{/if}}
{{#if $.Session.equals 'sessionName' value3}}
<p> value3 </p>
{{/if}}
I'm trying to use helpers, but can't get it to work:
{{#if 'helperName' value1}}
<p> value1 </p>
{{/if}}
{{#if 'helperName' value2}}
<p> value2 </p>
{{/if}}
{{#if 'helperName' value3}}
<p> value3 </p>
{{/if}}
Template.name.helpers({
helperName: function (item) {
return Session.equals('currentItem', item);
},
});
onBeforeAction: function() {
Session.set('currentLastItem', 'value1');
this.next();
}
And I get error statement that there is no such function as helperName
This is the same principle but used to render different data based on the current route - Meteor: Change the class of link on click
Upvotes: 1
Views: 41
Reputation: 2010
This would allow you to use the syntax you used above:
https://atmospherejs.com/raix/handlebar-helpers
Upvotes: 1