Reputation: 825
In Ember, I know that I can include classes with if statements using the {{if}} handlebar. However, how can I do this inside a component handlebar?
For example, how can I do something like this:
{{myComponent class="my-class {{if isThisTrue 'true-class' 'false-class'}}" }}
Upvotes: 1
Views: 707
Reputation: 693
You can use,
{{my-component class="my-class" classNameBindings="isThisTrue:true-class:false-class"}}
Upvotes: -2
Reputation: 6577
Since the curly braces can't be nested there is a syntax called nested helper to do so, and it works for most of the helpers like if
, unless
, concat
, and family:
{{myComponent class=(concat "my-class " (if isThisTrue 'true-class' 'false-class'))}}
You have to use concat
here since you're putting together a static and a dynamic portion of the string together.
Upvotes: 5