Skip to content

[6.x] Parse Antlers enabled fields in Blade templates - #15184

Open
duncanmcclean wants to merge 1 commit into
6.xfrom
parse-antlers-fields-in-blade
Open

[6.x] Parse Antlers enabled fields in Blade templates#15184
duncanmcclean wants to merge 1 commit into
6.xfrom
parse-antlers-fields-in-blade

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request fixes an issue where fields with the "Parse Antlers" option enabled wouldn't have their Antlers parsed when rendered in a Blade template.

This was happening because Antlers enabled fields are only ever parsed by the Antlers runtime, which calls Value::antlersValue() when it comes across one. Blade doesn't know anything about that, so echoing a Value falls through to __toString() and returns the augmented value with the Antlers left as-is.

This PR fixes it by registering a Blade echo handler for Value objects, which parses Antlers enabled fields using the cascade as their context. The same user content sandboxing the Antlers runtime applies is used here, so guarded tags and modifiers behave identically in both templating languages. Values without the option enabled are returned untouched.

Worth noting: Blade only picks up echo handlers when a view is compiled, so sites will need to run php artisan view:clear after upgrading before they'll see the fix.

Fixes #8430

Fields configured with `antlers: true` were only parsed by the Antlers
runtime, so blade templates echoed the raw tags. A blade echo handler
now runs `Value::antlersValue()` for those fields, using the cascade as
its context, with the same user content sandboxing the antlers runtime
applies.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

Antlers parsing in field doesn't work with blade templates

1 participant