The current thinking floating around for named yields looks something like this. You can't mix use of named blocks and non-blocked content. Once you use a block helper within a component, everything, including your main yield needs to be within one. If you don't use one, then your yielded content is the main block. This gist is a suggestion I have for how named yields should be implemented and work, and follows the evolution of my thinking on it.
** Only use the primary yield (existing syntax) **
** Utilize other named yields in addition to "main" **
The main issue with this syntax is that it doesn't mix elegantly with Glimmer Components
because of the alternating use of {{
and <
.
We could go with an approach that looks more like contextual components where blocks are part of the yield.
But directly relying on the contextual component implementation for this introduces potentially complicated/mistake-prone/incompatible wiring by the component's creator.
We could differentiate from named yields by auto-yielding a special
blocks
keyword.
The issue with our new block helpers is that you probably want to yield different content to different blocks.
For instance, let's say this is how you write the component's template for my-component
.
In our current syntax this would lead to foo
having a different value in each block, which is
unintuitive and not very ergonomic.
So let's follow the same guidlines as we did when we decided that "if you use the block helper, you must wrap all content within one, even the main yield". When you use the block helper, you don't yield your block params on the component. Here's what I mean.
for legacy:
I actually think this might be attainable in Ember currently all the way back to 1.11/1.12.
For 2.3+ we'd rely on contextual components. For < 2.3 we'd either polyfill contextual components or implement it with the
render
helper and special template=>partials compilation.