Skip to content
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

Provide context to the recursive children in the structure tag #2610

Merged
merged 1 commit into from
Oct 7, 2020
Merged

Provide context to the recursive children in the structure tag #2610

merged 1 commit into from
Oct 7, 2020

Conversation

duncanmcclean
Copy link
Member

This pull request fixes #2609 by providing context when using recursive children inside the nav/structure tag.

Currently, inside of recursive children, you're not able to see the data for the global page. In the below example, you wouldn't be able to access {{ current_url }} in any of the children.

{{ nav:collection:pages }}
    <li>current_url: {{ current_url or 'nada' }}</li>

    {{ if children }}
        {{ *recursive children* }}
    {{ /if }}
{{ /nav:collection:pages }}

The above example is something this PR fixes. It does this by providing the context available to the tag and merging it with the entry & structure data for the child.

@jasonvarga
Copy link
Member

Thanks!

@jasonvarga
Copy link
Member

FYI the context should have been added to start of the array merge.
This PR introduced a bug where variables inside the page were being overridden by variables named the same in the context.

e.g. if you're on the home page that has a title of Home, then all the nav item's {{ title }} would output Home.

Fixed in a8f3f47

@duncanmcclean
Copy link
Member Author

duncanmcclean commented Oct 8, 2020

Oh.... I actually put it at the end to prevent that but thinking of it now, it should have been the other way round. 🤦‍♂️ sorry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Global variables not available on {{ *recursive children* }}
2 participants