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!

Published by Corinna Baldauf

Corinna Baldauf has filled every Scrum role there is and then some. Currently she spends most of her days writing and occasionally facilitating retrospectives. She's interested in lean, agile, coaching, leadership & UX. You can follow her on Twitter, subscribe to her (Retromat) newsletter and buy her books.

One reply on “The NOT operator in Meteor.js (Spacebars, Handlebars)”

Comments are closed.