Skip to content

[6.x] Prevent variable conflicts with wildcard tags#11611

Merged
jasonvarga merged 5 commits intomasterfrom
tag-wildcards
Mar 24, 2025
Merged

[6.x] Prevent variable conflicts with wildcard tags#11611
jasonvarga merged 5 commits intomasterfrom
tag-wildcards

Conversation

@duncanmcclean
Copy link
Member

@duncanmcclean duncanmcclean commented Mar 21, 2025

Currently, when you do something like this in your template:

{{ nav:footer }}
    <!-- -->
{{ /nav:footer }}

Statamic will check if a footer variable exists in the tag's context and use its value, otherwise it'll fallback to the literal string, footer.

This behaviour is a little problematic, for example if you have a global called footer, but you also have a nav called footer. It would end up passing your augmented global as the handle for the nav, which obviously won't work.

This issue only affects a couple of our tags:

  • {{ session }}
  • {{ cookie }}
  • {{ nav }}
  • {{ redirect }}

We're doing similar things in the {{ dump }}, {{ asset }}, {{ get_content }} and {{ glide }} tags but the behaviour makes sense in those cases.

Fixes #10612
Fixes #10643

@jasonvarga jasonvarga merged commit 3a66bf8 into master Mar 24, 2025
19 checks passed
@jasonvarga jasonvarga deleted the tag-wildcards branch March 24, 2025 13:47
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.

2 participants