Handlebarsjs check if a string is equal to a value

后端 未结 13 767
挽巷
挽巷 2020-12-08 18:23

Is it possible in Handlebars to check if a string is equal to another value without registering a helper? I can\'t seem to find anything relevant to this in the Handlebars r

13条回答
  •  伪装坚强ぢ
    2020-12-08 19:02

    Handlebars has a conditional operator called 'equal' that takes two parameters:

    1.The variable

    2.what your checking if the variable contains.

    For examples, to check if 'status' contains 'Full Time':

    {{#equal status "Full Time"}}  //status is the variable and Full Time is the value your checking for.
        code to be executed
    {{else}}
        code to be executed
    {{/equal}}
    

提交回复
热议问题