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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With