Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Whitelisting which components can render within a block component #12968

Closed
olivierlesnicki opened this issue Feb 15, 2016 · 1 comment

Comments

@olivierlesnicki
Copy link

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.

@rwjblue
Copy link
Member

rwjblue commented Feb 15, 2016

I do not think there is a way to do this, but I'm not really sure why you would want to...

Either way I don't see this as a bug in the framework, which is what we use issues in this repo for. We track feature requests as issues in the github.com/emberjs/rfcs repo (and feature proposals as PR's to the same repo). Would you mind submitting over there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants