-
-
Notifications
You must be signed in to change notification settings - Fork 405
Description
I've seen this come up a few times in the past couple weeks. People are wanting a way to wrap yielded content with either a component, or a html tag.
the API I could see for this is maybe something like:
{{#each yield as |yieldItem index|}}
<p>
{{yieldItem}}
</p>
{{/each}}Allowing the invocation site to get each block-level tag-scape to be wrapped with <p>
<BlogPost>
<Abstract />
<Preface />
<Introduction />
...
</BlogPost>This'd be the equivalent of today's:
<BlogPost>
<p><Abstract /></p>
<p><Preface /></p>
<p><Introduction /></p>
...
</BlogPost>So, given that, we still need to worry about about back-compat, so to talk about semantics, and hopefully cover all the use cases:
Traditional yield
{{yield}}- yields everything
Iterable yield
{{#each yield as |yieldItem|}}
{{yieldItem}}
{{/each}}This is semantically the same as {{yield}} -- especially if the implementation of child content given to a block is always represented as an array.
<ul>
{{#each yield as |yieldItem index|}}
<li>{{yieldItem index}}</li>
{{/each}}
</ul>In block form, passing positional arguments to yield wouldn't be allowed. Any arguments that would be passed to yield are now passed to yieldItem.