Skip to content

[TASK] Provide current template path in renderingContext#1337

Merged
s2b merged 1 commit intomainfrom
task/runtimeExceptions
Mar 9, 2026
Merged

[TASK] Provide current template path in renderingContext#1337
s2b merged 1 commit intomainfrom
task/runtimeExceptions

Conversation

@s2b
Copy link
Copy Markdown
Contributor

@s2b s2b commented Mar 5, 2026

Previously, PHP code within the context of a template (most importantly
ViewHelpers, but also internal Fluid code) wasn't aware of the current
template context. This meant that exceptions couldn't refer to the
template file where the exception was actually triggered.

This change introduces the optional originalTemplatePath value both
in the parser/compilation and in the rendering layer. When filled, it
contains the full path to the template that is currently parsed or
rendered. Since the value is also persisted to the cache, this path
is even available for cached template files.

In follow-up patches, this path can be used to improve exception
messages within Fluid. It also allows users to access these values to
improve exception messages in their own implementations.

@s2b s2b force-pushed the task/runtimeExceptions branch 5 times, most recently from 60b0725 to e3e2878 Compare March 5, 2026 18:20
@s2b s2b changed the title WIP: Add more context to runtime exceptions [TASK] Provide current template path in renderingContext Mar 5, 2026
@s2b s2b force-pushed the task/runtimeExceptions branch 2 times, most recently from fb3f839 to 5de7aed Compare March 7, 2026 11:40
@s2b s2b marked this pull request as ready for review March 7, 2026 11:42
Previously, PHP code within the context of a template (most importantly
ViewHelpers, but also internal Fluid code) wasn't aware of the current
template context. This meant that exceptions couldn't refer to the
template file where the exception was actually triggered.

This change introduces the optional `originalTemplatePath` value both
in the parser/compilation and in the rendering layer. When filled, it
contains the full path to the template that is currently parsed or
rendered. Since the value is also persisted to the cache, this path
is even available for cached template files.

In follow-up patches, this path can be used to improve exception
messages within Fluid. It also allows users to access these values to
improve exception messages in their own implementations.
@s2b s2b force-pushed the task/runtimeExceptions branch from 5de7aed to 087be63 Compare March 7, 2026 11:51
@s2b s2b merged commit 6d3d9c2 into main Mar 9, 2026
10 checks passed
@s2b s2b deleted the task/runtimeExceptions branch March 9, 2026 13:24
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