Reputation: 14815
I'd like to edit the content of the yield passed to a block component.
For example, having:
{{#no-foo}}foo{{/no-foo}}
Should output:
<div id="emberxxxx">bar</div>
Because I'd like to have something inside my component logic like this:
init: function() {
this.set('yield', this.get('yield').replace('foo', 'bar'));
}
Is it something possible with Ember.js?
Upvotes: 0
Views: 341
Reputation: 1654
I would not advise this approach. It seems like a hard-coded solution which assumes there will always be a foo
inside the block.. in which case: "why yield a block for foo
at all?"
Instead I would consider creating a computed property for the foo
so you can compute/change it how you want... then yield the computed property into the block.
// component.hbs
{{yield computedFoo}}
// main template
{{#my-component as |computedFoo|}}
{{computedFoo}}
{{/my-component}}
Upvotes: 1