I didn't find this was possible in Handlebars... I need something like this:
{{#if A || B || C}} something {{/if}}
Is that possible to achieve? I have looked at this answer, but as I need for 3 variables (A, B, C) I don't really know how to apply it. Any ideas?
Handlebars supports {{else if}} blocks as of 3.0. 0. is the point in not having an elsif (or else if) in handlebars that you are putting too much logic into your template.
You can use the logical AND (&&) and logical OR (||) operators to specify multiple conditions in an if statement. When using logical AND (&&), all conditions have to be met for the if block to run.
To iterate over an object with JavaScript and Handlebars. js, we can use the #each keyword. to add the Handlebars script and the template for looping through each entry in data . We use #each this to loop through each array property.
They do not have multiple conditions. But you can achieve it by nesting. This works:
{{#if A}} {{#if B}} {{#if C}} something {{/if}} {{/if}} {{/if}}
What about this?
{{#if A}} something {{else if B}} someting B {{else if C}} someting C {{/if}}
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