Handlebars: multiple conditions IF statement?

2019-06-15 01:44发布

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?

2条回答
▲ chillily
2楼-- · 2019-06-15 01:58

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}}
查看更多
forever°为你锁心
3楼-- · 2019-06-15 02:11

What about this?

    {{#if A}}
      something
    {{else if B}}
      someting B
    {{else if C}}
      someting C
    {{/if}}
查看更多
登录 后发表回答