shawnXiao shawnXiao - 2 years ago 158
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"

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download