Reputation: 8758
How can I join a static string and a dynamic property to pass to a helper?
The following does not work:
{{svg 'icon-' model.prop1}}
Thanks
Upvotes: 0
Views: 396
Reputation: 516
This is the wrong approach. Either compute the final name of your icon in the controller or view, or create a new property in your model called icon e.g.
DS.Model.extend({
icon: function() {
return 'icon-' + this.get('prop1').toLowerCase();
}.property('prop1');
....
controller/view:
icon: function() {
return 'icon-' + this.get('model.prop1').toLowerCase();
}.property('model.prop1');
Upvotes: 1
Reputation: 2309
You could implement a custom helper that concatenation two values then use it as a subexpression, e.g. 'concat'
{{svg (concat 'icon-' model.prop1)}}
Upvotes: 2