Conditional class in HtmlBars

jax picture jax · Mar 9, 2015 · Viewed 15.1k times · Source

In regular handlebars I was able to do:

<div {{bind-attr class="model.isNew:new:old"}}>

How can I do this in Htmlbars? I tried this but it didn't work.

<div class="{{model.isNew:new:old}}">

Answer

GJK picture GJK · Mar 9, 2015

This was mentioned in the 1.10 release/1.11 beta blog post:

<div class="{{if model.isNew 'new' 'old'}}">

You can also still use the {{bind-attr}} helper, although I think it might be deprecated.