Best way to test equality of two values in Blaze?

hi i,m newer with METEOR

if (currentUser == Author){
// this is post owner
} else {
// this is not
}

i need to check post owner with current login user id while list post on list page (client)
how do with blaze?

You can create your own global handler like this

$eq: function(a,b) {
    return a == b;
}

and in your Blaze template

{{#if $eq value1 value2}}
        <div> ...</div>
{{else}}
        <div> ... </div>
{{/if}}

Or, even better use proper handlers in your template to check if the current post is owned by the user.

{{#each post in posts}}
   {{#if currentUserOwner}}
   {{/if}}
{{/each}}
1 Like