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

Recent {{ nocache }} tag improvements break templates with PHP code or custom tag #9110

Closed
duncanmcclean opened this issue Dec 4, 2023 · 0 comments · Fixed by #9124
Closed

Comments

@duncanmcclean
Copy link
Member

duncanmcclean commented Dec 4, 2023

Bug description

After the recent improvements to the {{ nocache }} tag in #8956, the variables used in custom PHP code or custom tags inside the {{ nocache }} tag content are available.

This is happening because Antlers now attempts to extract the relevant variables from the {{ nocache }} tag's contents. This extraction is bypassed if partials are being called inside the tag or if the Regex parser is being used.

We should probably also bypass this extraction logic when using custom PHP code (unless we can extract them too?) or using custom tags.

How to reproduce

PHP code

Original: #9001 (comment)

{{ nocache }}
      <div>
          {{$ App\Support\Paddle::priceForMonthlyPlan($plan_type) $}}
      </div>
      <div>
          {{$ App\Support\Paddle::priceForYearlyPlan($plan_type) $}}
      </div>
{{ /nocache }}

The plan_type variable is not

Tags

Original: #8956 (comment)

{{ nocache }}
    {{ custom_tag }}
{{ /nocache }}

Workaround

This issue can be easily worked around by specifying the variables that should be cached using the select parameter on the {{ nocache }} tag:

{{ nocache select="the_limit|url|title" }}
    <!-- whatever code... -->
{{ /nocache }}

Logs

No response

Environment

Any version since v4.34.0, when #8956 was tagged.

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

runtime (new)

Additional details

No response

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

Successfully merging a pull request may close this issue.

1 participant