-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Passing of tag content from f:render to partial/section
Allows a completely new approach to structuring Fluid template rendering, allowing partials and sections to be used as "wrappers" for an arbitrary piece of template code. Consider the following example: ```xml <f:section name="MyWrap"> <div> <!-- And LOTS more HTML, using variables if desired --> <!-- Tag content of f:render output: --> {contentVariable -> f:format.raw()} </div> </f:section> <f:render section="MyWrap" contentAs="contentVariable"> This content will be wrapped. Any Fluid code can go here. </f:render> ``` The result is that the tag content of `f:render` is assigned as the template variable `{contentVariable}` which can then be used in the template code that is in the section/partial. It's the same as passing a big chunk of Fluid to the `arguments` array as a variable there, and using it the same way - but it is a lot easier on the syntax. The new structure approach is enabled because `f:render` can then be used recursively to wrap your template code in any number of wraps (imagine the `f:section` tags with content similar to above): ```xml <f:render partial="OuterWrap" contentAs="contentVariable"> <f:render partial="InnerWrap" contentAs="contentVariable"> <f:render partial="ItemWrap" contentAs="contentVariable"> <h2>My item, nicely wrapped</h2> <p>Nice.</p> </f:render> </f:render> </f:render> ``` Which would render as follows: 1. Outermost wrap renders tag content and assigns as variable for second level 2. Second level wrap renders tag content and assigns as variable for innermost level 3. Innermost level renders the actual content you wish to wrap and assigns it as variable 4. The innermost "wrap" partial/section is rendered (because no more `f:render` children exist) 5. The second level "wrap" partial/section is rendered with the HTML from step 4 as content variable. 6. The outer level "wrap" partial/section is rendered with the HTML from step 5 as content variable. 7. The entire thing is output.
- Loading branch information
1 parent
b660cf5
commit 454121c
Showing
2 changed files
with
90 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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