Handlebars: multiple conditions IF statement?

谁说胖子不能爱 提交于 2019-12-10 12:29:54

问题


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?


回答1:


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}}



回答2:


What about this?

    {{#if A}}
      something
    {{else if B}}
      someting B
    {{else if C}}
      someting C
    {{/if}}


来源:https://stackoverflow.com/questions/41251635/handlebars-multiple-conditions-if-statement

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!