Fix data being passed into recursive vars #2719
Merged
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 fixes an issue that #2610 introduced.
While that PR looked like it was working fine, it was actually causing data to be overridden where it wasn't supposed to.
This PR reverts that PR, and fixes the underlying issue instead.
One of the most common examples of this is a nav where you have alternative titles (here, a
nav_title
var).This will work fine until you're actually on a page that has a nav_title. Then the nav_title of the actual page will trickle down into every item of the nav loop.
A workaround for this is to use the
scope
parameter to say "I want a variable from this iteration without the parent context leaking into it".PR 2610 broke this behavior by merging the context into every iteration. The scoped variable would no longer only have its own values.
The issue that 2610 was trying to solve was the make the top level variables (like current page vars, globals, etc) available inside the recursive children. Instead, the parser will now merge the data appropriately. The structure tag doesn't need to do it.