feat: add #blank, #solo, #inject, and #slot directives to Odo templat…#231
Merged
techmahedy merged 1 commit intodoppar:3.xfrom Mar 15, 2026
Merged
feat: add #blank, #solo, #inject, and #slot directives to Odo templat…#231techmahedy merged 1 commit intodoppar:3.xfrom
techmahedy merged 1 commit intodoppar:3.xfrom
Conversation
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.
This PR introduces four new built-in directives to the Odo template engine — #blank/#endblank, #notblank/#endnotblank, #solo/#endsolo, and #inject/#slot. These directives cover common template patterns that previously required raw PHP or verbose #if workarounds.
#blank / #endblank
#solo / #endsolo
Renders its content block only once per request, even if the surrounding template or partial is included or looped multiple times. This is critical for preventing duplicate <script> and tags when including partials inside loops.
Even if the loop runs 100 times, the <script> and tags are rendered exactly once. Without this directive, developers had to manage their own deduplication flags in raw PHP.
#inject / #endinject and #slot
Introduces a named content stack system. Views and partials can push content into named stacks using #inject, and layouts can output the accumulated content anywhere using #slot. Multiple #inject calls into the same stack are rendered in the order they were pushed.
Define slot placeholders in your layout:
Push content from any view or partial: