Skip to content

Conversation

@s2b
Copy link
Contributor

@s2b s2b commented Oct 11, 2025

Fluid has so far removed any CDATA sections from templates. This has
been introduced with 978071f, without any clear indication why this
was done. This means that Fluid templates either expect CDATA sections
to be removed or avoid them altogether since they don't do anything.
This gives us the opportunity to not only re-add those sections to
Fluid templates (which is a breaking change), but to also introduce
new syntax within those section.

One common issue with the Fluid parser has always been that the
variable/inline syntax collides with both CSS and JS, which both use
curly braces quite extensively. In most cases, this leads to the
Fluid parser trapping over a curly brace that's not intended for Fluid
and then stops interpreting valid Fluid syntax after that.

This patch extends the Fluid parser to use alternative variable and
inline syntax within CDATA sections in the template. Both ViewHelper
tag syntax and the normal curly braces syntax no longer work there,
instead three curly braces {{{ }}} can be used to access Fluid
variables, call ViewHelpers and use expressions. The CDATA keyword
itself is removed from the output.

Resolves: #1012
Resolves: #808

@s2b s2b force-pushed the feature/cdataEscaping branch from 85b292a to fbadebe Compare October 11, 2025 18:58
@s2b s2b force-pushed the feature/cdataEscaping branch 4 times, most recently from 9dd8423 to 3f292e7 Compare October 11, 2025 19:37
Fluid has so far removed any CDATA sections from templates. This has
been introduced with 978071f, without any clear indication why this
was done. This means that Fluid templates either expect CDATA sections
to be removed or avoid them altogether since they don't do anything.
This gives us the opportunity to not only re-add those sections to
Fluid templates (which is a breaking change), but to also introduce
new syntax within those section.

One common issue with the Fluid parser has always been that the
variable/inline syntax collides with both CSS and JS, which both use
curly braces quite extensively. In most cases, this leads to the
Fluid parser trapping over a curly brace that's not intended for Fluid
and then stops interpreting valid Fluid syntax after that.

This patch extends the Fluid parser to use alternative variable and
inline syntax within CDATA sections in the template. Both ViewHelper
tag syntax and the normal curly braces syntax no longer work there,
instead three curly braces `{{{ }}}` can be used to access Fluid
variables, call ViewHelpers and use expressions. The CDATA keyword
itself is removed from the output.

Resolves: #1012
Resolves: #808
@s2b s2b force-pushed the feature/cdataEscaping branch from 3f292e7 to 7ce1f4e Compare November 3, 2025 18:34
@s2b
Copy link
Contributor Author

s2b commented Nov 3, 2025

TODO: We may declare this as experimental for now.

@s2b
Copy link
Contributor Author

s2b commented Nov 4, 2025

TODO: We may declare this as experimental for now.

Since the impact on existing templates will be pretty small, we will not declare it as experimental.

@s2b s2b merged commit f5377f0 into main Nov 4, 2025
10 checks passed
@s2b s2b deleted the feature/cdataEscaping branch November 4, 2025 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't remove CDATA sections from templates Template parser issue when using curly braces for inline js or css

3 participants