-
-
Notifications
You must be signed in to change notification settings - Fork 181
fix: layout snippet inside of snippet (#7567) #7571
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
base: develop-patch
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,31 +163,8 @@ public function render(array $data = []): string | |
// load the template | ||
$template = Tpl::load($this->file(), $data); | ||
|
||
// if last `endsnippet()` inside the current template | ||
// has been omitted (= snippet was used as layout snippet), | ||
// `Snippet::$current` will point to a snippet that was | ||
// opened inside the template; if that snippet is the direct | ||
// child of the snippet that was open before the template was | ||
// rendered (which could be `null` if no snippet was open), | ||
// take the buffer output from the template as default slot | ||
// and render the snippet as final template output | ||
if ( | ||
Snippet::$current === null || | ||
Snippet::$current->parent() !== $snippet | ||
) { | ||
return $template; | ||
} | ||
|
||
// no slots have been defined, but the template code | ||
// should be used as default slot | ||
if (Snippet::$current->slots()->count() === 0) { | ||
return Snippet::$current->render($data, [ | ||
'default' => $template | ||
]); | ||
} | ||
|
||
// let the snippet close and render natively | ||
return Snippet::$current->render($data); | ||
// handle any potentially open layout snippet | ||
return Snippet::endlayout($snippet, $template, $data); | ||
JojOatXGME marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that any output from before opening the layout snippet gets discarded. This was already the case before. I think ideally, we should call |
||
} | ||
|
||
/** | ||
|
Uh oh!
There was an error while loading. Please reload this page.