Reputation: 12960
In the following example I have registered an helper "currentUser" in a file utils.js in the lib folder of the client. I am trying to align the messages right or left if the condition satisfies.
<template name="chatMessages">
{{#each chatMessages}}
{{#if currentUser {{email}}}}
<b style="float:right;">{{message}}</b>
<br>
{{else}}
<b style="float:left;">{{message}}</b>
<br>
{{/if}}
{{/each}}
The helper code is:
Template.registerHelper("currentUser", function(input) {
return Session.get("userMail") === input;
});
Upvotes: 0
Views: 72
Reputation: 20256
Don't put the parameter to the helper inside curly braces, i.e. instead of:
{{#if currentUser {{email}}}}
use
{{#if currentUser email}}
Assuming that the variable email
is defined in the data scope of the helper! (you don't show that part).
Upvotes: 3