shawnXiao shawnXiao - 6 months ago 3
Javascript Question

Is there a ternary operator in handlebars.js?

In Handlebars, is there a ternary operator? I don't mean

if else
; I mean like
a == true ? "a" : "b"


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.