-
-
Notifications
You must be signed in to change notification settings - Fork 600
Closed
Labels
Description
Bug Description
The order in which yield and section tags are used can affect the result.
For example, if the yield tag is parsed before the corresponding section tag, it won't work.
How to Reproduce
Use a yield tag before a section tag. The example provided to us was a dark mode toggle with accompanying js that needed to go in the head.
// layout
<html>
<head>
{{ yield:dark_mode }}
</head>
<body>
<nav>
...
{{ partial:dark_mode_toggle }}
</nav>
{{ template_content }}
</body>
// dark_mode_toggle
<button>toggle</button>
{{ section:dark_mode }}
<script>some js</script>
{{ /section:dark_mode }}
If the section tag was used inside the template it would work, because the template (and therefore the section tag) would be parsed before the layout.
Extra Detail
A solution might be to change how the yield tag works.
Maybe it could output a placeholder string rather than performing the replacement right there.
Then, after the whole view (template+layout) has been rendered, it could replace all the yields.
Environment
Statamic version: 3.0.44
edalzell, robdekort, jonassiewertsen, jelleroorda, aerni and 1 more