The NOT operator in Meteor.js (Spacebars, Handlebars)

Because a colleague praised Meteor.js I’m currently working through the tutorial and was stumped by trying to create an “if not” condition. Neither {{#if !myVar}} nor {{#if not myVar}} worked.

Maybe it’s just my inability to google, but I did not find the solution as quickly as I would have expected, so is there a NOT operator in Meteor? Can I negate an if condition?

The answer is “kind of”. You’re probably looking for:

{{#unless myVar}} ... {{/unless}}

unless is the opposite of if
(Source)

I also learned that Meteor’s templating mechanism is called “Spacebars“, which is derived from “Handlebars.js”. Both know “unless”.

PS: The colleague was completely right about Meteor: It’s awesome! I love it! You should totally try it!

Share this article:

1 Comment The NOT operator in Meteor.js (Spacebars, Handlebars)

Leave a Reply

Your email address will not be published. Required fields are marked *