Timtim
Timtim

Reputation: 344

Meteor : get the opposite statement from a variable into handlebars

I'm discovering Meteor and was asking myself for a thing. How in a template can we reverse the boolean into the handlebars from a template ?

There is an example of what I'm trying to do :

task.html

<li class="{{#if !checked}}checked{{/if}}">
    ...

But I'm getting an error "Expected close "}}". Maybe it's not possible.

Thank you !

Upvotes: 0

Views: 106

Answers (2)

Joey Etamity
Joey Etamity

Reputation: 866

There is no ! syntax handling in the template. Neither {{#if !myVar}} nor {{#if not myVar}} worked.

You need to remove ! from !checked:

<li class="{{#if checked}}checked{{/if}}">

Or you can use unless:

<li class="{{#unless checked}}checked{{/unless}}">

Upvotes: 1

Ilshidur
Ilshidur

Reputation: 1521

Here is your solution : How to IF NOT inside of {{ #each }} template

Use {{#unless}} :

Example of use :

{{#unless checked}}
    ....
{{/unless}}

Upvotes: 1

Related Questions