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

[FEATURE] Fluid code in comments no longer interpreted #956

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

s2b
Copy link
Contributor

@s2b s2b commented Aug 11, 2024

Previously, the behavior of the <f:comment> ViewHelper was confusing:
Even if invalid Fluid code (e. g. syntax errors or a non-existent ViewHelper)
was wrapped with <f:comment>, it would still be interpreted by the
Fluid parser and an exception would be thrown.

This patch resolves this similarly to CDATA handling. It introduces a new
TemplateProcessor, which is executed before any other parsing and strips
out the contents of Fluid comments. The <f:comment> ViewHelpers are
kept intact and are filled with empty lines. This can be helpful when
debugging Fluid templates because the line numbers in exceptions are
consistent to the original template file.

This new TemplateProcessor is then registered in the default
RenderingContext implementation. For systems that set their own
TemplateProcessors, this would probably need adjustments. However,
this change is not breaking since the old functionality is still there.

Fluid's own tests however now assume that this new TemplateProcessor
is registered and are adjusted properly in this patch.

@s2b s2b force-pushed the feature/commentRemoval branch 4 times, most recently from 1bcbc40 to 1276ec0 Compare August 11, 2024 09:45
@s2b
Copy link
Contributor Author

s2b commented Aug 11, 2024

Resolves #894

Previously, the behavior of the `<f:comment>` ViewHelper was confusing:
Even if invalid Fluid code (e. g. syntax errors or a non-existent ViewHelper)
was wrapped with `<f:comment>`, it would still be interpreted by the
Fluid parser and an exception would be thrown.

This patch resolves this similarly to CDATA handling. It introduces a new
TemplateProcessor, which is executed before any other parsing and strips
out the contents of Fluid comments. The `<f:comment>` ViewHelpers are
kept intact and are filled with empty lines. This can be helpful when
debugging Fluid templates because the line numbers in exceptions are
consistent to the original template file.

This new TemplateProcessor is then registered in the default
RenderingContext implementation. For systems that set their own
TemplateProcessors, this would probably need adjustments. However,
this change is not breaking since the old functionality is still there.

Fluid's own tests however now assume that this new TemplateProcessor
is registered and are adjusted properly in this patch.
@s2b s2b merged commit faad81a into main Aug 12, 2024
8 checks passed
@s2b s2b deleted the feature/commentRemoval branch August 12, 2024 12:21
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