3

Is it possible to use logical operators in Spacebars (without template helpers)?

For example:

{{#if status == '0'}}
      Hello world.
{{/if}}

Unfortunately, I get the following error:

   While processing files with templating (for target web.browser):
   client/views/test.html:46: Expected identifier, number, string, boolean, null, or a sub expression enclosed in "(", ")"
   ...       {{#if status == '0'}}             ...
   ^

=> Your application has errors. Waiting for file change.
user3475602
  • 1,217
  • 2
  • 21
  • 43

1 Answers1

6

Spacebars can't into comparison, but you can use native underscore for it. Register it on client with:

Template.registerHelper('_', function(){
  return _;
});

and then use it like this:

{{_.isEqual status 0}}

It return true if status is 0 or false otherwise.

Akhar
  • 108
  • 6