-
-
Notifications
You must be signed in to change notification settings - Fork 405
Description
It looks like the framework doesn't support a default way of whitelisting which components can render within its yield.
{{#parent-component
as |first-child second-child|
}}
{{first-child}}
{{second-child}}
Hello World.
{{/parent-component}}The requirement is to be able to render {{first-child}} and {{second-child}} because they're components supplied by the parent-component but not render "hello world." or any other component/data for that matter.
A workaround is today's possible with ember-wormhole where the parent-component can have the following template:
// parent-component
<div id="first-child">
</div>
<div id="second-child">
</div>
<div style="display:none;">
{{yield}}
</div>And the first-child:
// first-child
{{ember-wormhole to="first-child"}}
...
{{/ember-wormhole}}While it does achieve the required requirement I think it's important for a framework that offers composability to be able to handle.
Because react requires you to define the template within the render hook you're able to do it quite easily:
render() {
return (
<div>
{this.props.children.filter(child => {
return child instaceof FirstChild || child instanceof SecondChild;
})
</div>
);
}
Maybe there's a way to do it which I wasn't able to find on StackOverflow nor ember set of documentation.
(originally raised emberjs/ember.js#12968)