Reputation:
Obviously super new to Ember. Couldn't find an example of what I'm looking to do in docs. Anyway, I have some code like this:
{{#if (eq type 1)}}
<span>
{{convert-type measurement showUnits=true myUnits=myUnits}}
</span>
{{else}}
<span>{{convert-type measurement showUnits=true}}</span>
{{/if}}
And it seems pretty verbose. I want to do something like:
<span>
{{convert-type
measurement
showUnits=true
(if (eq type 1) myUnits=myUnits) }}
</span>
But I keep getting template errors. :/ Is this possible?
Upvotes: 2
Views: 48
Reputation: 141
If think better method is to use computed property:
myUnitsPrim: computed('type', 'myUnits.[]', function() {
return this.get('type') === 1 ? this.get('myUnits') : null;
})
and then
{{convert-type
measurement
showUnits=true
myUnits=myUnitsPrim }}
or just:
{{convert-type
measurement
showUnits=true
myUnits=(if (eq type 1) myUnits null) }}
Upvotes: 4