[6.x] Include Tag - #15182
Open
JohnathonKoster wants to merge 2 commits into
Open
Conversation
JohnathonKoster
marked this pull request as draft
August 13, 2026 07:31
JohnathonKoster
marked this pull request as ready for review
August 13, 2026 17:29
Member
|
Looking forward to using this! After a review and playing around, got a couple things I want to make sure are intentional: Blade → Antlers cascade — If I do scope punching out — Using
|
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.
Fixes #8175
Fixes #10703
Fixes #11486
Fixes #12709
Overview
This PR adds a new
includetag: a strictly-scoped alternative topartialfor rendering another view, available in both Antlers and Blade.The
partialtag automatically shares every variable from the template using it with the partial being rendered. That convenience is the root cause of a long line of historical scoping issues and little paper-cuts. Variables set inside a partial leaking back out (but only sometimes), parameters and front matter showing up in other partials rendered later on the page, and behavior changing depending on which syntax was used.Fixing these issues with the existing
partialtag would absolutely break a ton of sites, soincludeis here!How it differs from
partialpartialincludecascade="true"Passing data
You must pass data to the include tag explicitly. Parameters become variables inside the view, and you can spread an entire array using
:params. Inside the view, useparamsto check what was passed in:Use
handle_prefixto make prefixed keys likehero_titleavailable as bothhero_titleandtitle:Slots
Content between the tag pair becomes the default slot, and you can define named slots with
slot:namepairs.Slots only render when the view actually uses them, and the view can pass data back to your slot content. A view can render a slot once per item in a loop, for example:
You can also forward a slot you received on to another include:
The Cascade
Included views don't see the Cascade by default. Pass
cascade="true"when you want it:Conditionals and existence
Use
whenandunlessto control whether anything renders.existsandif_existswork the same way they do onpartial:The issues
includethey never do.view:data of the next one rendered on the page. Each include only sees its own.{{ if }}and using the?=shorthand isolate variables differently. Both behave the same withinclude.Notes for reviewers
handle_prefix, the prefix rewrites variable lookups in everything rendered inside it. The include tag suspends this while it renders, so an enclosing partial's prefix never reaches the included view. Components rendered inside such a partial still inherit the prefix. That is probably unintentional, but changing it could break existing sites, so it's left alone for now.