Is there a ternary operator in handlebars.js?

后端 未结 4 1183
说谎
说谎 2021-01-07 19:15

In Handlebars, is there a ternary operator? I don\'t mean if else; I mean like a == true ? \"a\" : \"b\".

4条回答
  •  無奈伤痛
    2021-01-07 19:34

    You can build your own helper in handlbars if you really want to. Something like ternary(a==true, "a", "b"). For more information on that see the documentation. The idea from m90 is not the idea behind handlebars. The idea is to not have explicit code in your templates, only calls to helpers and objects.

提交回复
热议问题