0

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 !

Timtim
  • 324
  • 8
  • 18

2 Answers2

1

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

Use {{#unless}} :

Example of use :

{{#unless checked}}
    ....
{{/unless}}
Community
  • 1
  • 1
Ilshidur
  • 1,461
  • 14
  • 11
1

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}}">
Joey Etamity
  • 856
  • 4
  • 9
  • Yeah, it's weird we can't find it easily in the documentation. Thank you for your response ! – Timtim Jul 18 '16 at 10:40