Is there a way to do logic operation in {{#if}} statement? I was hoping for something like:
{{#if A && B}}
some html
{{/if}}
I couldn’t find documentation about logic in blaze, so I guess it’s not supported. I just wanted to be sure. Sorry for the rather stupid question...
here is my version :
You can now use x arguments to check, like :
You will notice the slice(0,-1), Blaze add one more argument to the function.
As Billy Bob suggests, you would need parameterized helpers. Here are two global helpers you could use in any context:
Then you could use these with:
Spacebars is designed to avoid including logic operations in the html. But it does not mean you can't have one : you need to use helpers. Basically, you have 2 conditional cases:
The simple
{{#if something}}
and its twin{{#unless something}}
(understand it as "if not"). This is what you want, and your helper would look like thisThe more complicated
{{#if something 'value'}}
where you use an argument for yoursomething
helper :