-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Implement partial blocks #1076
Implement partial blocks #1076
Conversation
This is the documentation for handlebars-lang/handlebars.js#1076
@mmun @wycats could I get your input on this? Trying to carve off pieces from #1018 that can go out in a more standalone fashion vs. a big bang meta feature. My biggest questions here are:
Documentation PR here: wycats/handlebars-site#120 |
This is the documentation for handlebars-lang/handlebars.js#1076
962989b
to
2a933fd
Compare
Ember doesn't support
|
7fa69a8
to
3c4ea7c
Compare
|
Since the whitespace constraints are different I don't have anything useful to add. Is FWIW, I am still interested in the original named blocks proposal. EDIT: Ah the numbering got messed up on your comment (Thanks markdown!) I'll comment again shortly. |
In ember you can write something like {{#each-with-ul items=people as |p|}}
Hello {{p.name}}
{{/each-with-ul}} where the <ul>
{{#each items as |item|}}
<li>{{yield item}}</li>
{{/each}}
</ul> This generates the output (ignoring whitespace)
I assume Thorax has something similar. The win here is that the scope of the second template above is completely encapsulated so its easier to reason about and easier to reuse. Aligning Handlebars with |
This allows for failover for missing partials as well as limited templating ability through the `{{> @partial-block }}` partial special case. Partial fix for #1018
Avoid duplicating the logic needed to check for close block mismatches.
3c4ea7c
to
1c27408
Compare
I'm having trouble working through your comments about encapsulation and leaking contexts or how this is different from the helper block-based ember example above. Can you help me understand that? Regarding named blocks, the decorators branch implements a generic way to apply metadata to blocks and wrap in behaviors as well as implements the inline partials behavior that is the end goal. This PR needs to land before can do too much discussion on that, unfortunately. |
Forget it, the docs give an example that removes my concerns. {{#each children as |child|}}
{{#> childEntry}}
{{child.value}}
{{/childEntry}}
{{/each}} This works as expected, even if your childEntry partial was something like {{#with somethingElse as |child|}}
{{> %block}}
{{/with}} it wouldn't cause any shadowing of |
Sounds like we're mostly in agreement then. Leaving the token name as |
Released in 4.0.0 |
This allows for failover for missing partials as well as limited templating ability through the
{{> @partial-block }}
partial special case.Partial fix for #1018