Implicit default block for embeds - #419
Merged
Merged
Conversation
Member
|
Thanks! |
dg
pushed a commit
that referenced
this pull request
Jun 21, 2026
dg
pushed a commit
that referenced
this pull request
Jun 21, 2026
dg
pushed a commit
that referenced
this pull request
Jun 22, 2026
|
Great feature! I've been hoping for this for a while! I've just noticed a small bug though. Using |
Contributor
Author
|
@jan-herman Interesting. It's probably best if you open a new issue on the repo, along with the exact latte template that triggers the error for you. |
Member
|
@jan-herman fixed |
dg
pushed a commit
that referenced
this pull request
Jun 28, 2026
dg
pushed a commit
that referenced
this pull request
Jul 4, 2026
dg
pushed a commit
that referenced
this pull request
Jul 19, 2026
dg
added a commit
that referenced
this pull request
Jul 19, 2026
A block declared inside a top-level condition or loop of the {embed}
content (single, duplicate or dynamically named) registers according to
the flow of execution: {embed} executes the registration code in
collecting mode before the embedded template renders. Adds the runtime
collecting machinery (collectBlocks/collectBlock); child templates are
not affected yet. Complements the implicit default block for {embed}
(#419).
To be released in 3.1.
dg
pushed a commit
that referenced
this pull request
Jul 25, 2026
dg
added a commit
that referenced
this pull request
Jul 25, 2026
A block declared inside a top-level condition or loop of the {embed}
content (single, duplicate or dynamically named) registers according to
the flow of execution: {embed} executes the registration code in
collecting mode before the embedded template renders. Adds the runtime
collecting machinery (collectBlocks/collectBlock); child templates are
not affected yet. Complements the implicit default block for {embed}
(#419).
To be released in 3.1.
dg
pushed a commit
that referenced
this pull request
Jul 25, 2026
dg
added a commit
that referenced
this pull request
Jul 25, 2026
A block declared inside a top-level condition or loop of the {embed}
content (single, duplicate or dynamically named) registers according to
the flow of execution: {embed} executes the registration code in
collecting mode before the embedded template renders. Adds the runtime
collecting machinery (collectBlocks/collectBlock); child templates are
not affected yet. Complements the implicit default block for {embed}
(#419).
To be released in 3.1.
dg
added a commit
that referenced
this pull request
Jul 25, 2026
A block declared inside a top-level condition or loop of the {embed}
content (single, duplicate or dynamically named) registers according to
the flow of execution: {embed} executes the registration code in
collecting mode before the embedded template renders. Adds the runtime
collecting machinery (collectBlocks/collectBlock); child templates are
not affected yet. Complements the implicit default block for {embed}
(#419).
To be released in 3.1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Provide an implicit
defaultblock forembeds and move any "loose" children into that default block.Mirrors how other templating libraries deal with default/unnamed slots.
Current state
Currently, I manually have to define the default block when embedding.
It's a lot of noise when using many embeds.
With this feature
This will move any "loose" children into an implicit
defaultblock that the template file can render as necessary.{embed button} - {block default} Submit - {/block} {/embed}Explicit blocks and the implicit default block can live side by side.
Explicit and implicit
defaultblock can never coexist and end up with a new compile error.Tests
Tests are added.
Nonbreaking
No existing tests have been modified.
Templates currently using a
defaultblock will keep working.Also, this does not automatically render the loose content. Loose content is still ignored, just as before. It requires defining a
{block default}inside the embedded content.Alternative implementation
I was thinking of using an unnamed block instead of a default block. Not sure if that would've worked even? Also, I think
defaultreads more intentional and in line with how most templating engines name their default slots.