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}}">
Join Stack Overflow to learn, share knowledge, and build your career.
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.
{{bind-attr class="isFoo"}}
style, which automatically generated the is-foo
class. Now I have to write class="{{if isFoo 'is-foo'}}"
. A step backward. In the syntax class="{{isFoo}}"
, if isFoo
is boolean, it should mimic the old behavior by generating class="is-foo"
instead of the meaningless class="true"
.
– user663031
Apr 20 '15 at 13:59
{{toggle-class isFoo}}
. You can even use subexpressions. bind-attr
was cool when it's all we had, but the sky is the limit now!
– GJK
Apr 20 '15 at 14:02