TYPO3 / Fluid

Fluid template rendering engine - Standalone version
GNU Lesser General Public License v3.0
151 stars 93 forks source link

Allow invalid Fluid tags inside f:comment #894

Closed georgringer closed 2 weeks ago

georgringer commented 1 month ago

this is a duplicate of https://forge.typo3.org/issues/97835 to have it in correct project

Currently i update all if i wrap this widget with f:comment the f:widget.paginate still throws an error. I now i have to remove this widget, but for testing i want wrap this in a comment to write the new code. i think fluid should ignore code which is wrapped with comments

mbrodala commented 1 month ago

Not 100% sure but I think this can be achieved with the (badly named) <f:cache.disable> viewhelper:

https://github.com/TYPO3/Fluid/blob/8aa5b45d6a72db65a45cefa8f75fd9be2626542e/src/ViewHelpers/Cache/DisableViewHelper.php

georgringer commented 1 month ago

wtf about the name

mbrodala commented 1 month ago

Yup. In any case this doesn't work:

<f:cache.disable><f:widget.paginate></f:widget.paginate></f:cache.disable>

This still throws the The ViewHelper "<f:widget.paginate>" could not be resolved. error.

s2b commented 1 month ago

Side note: These cache.* ViewHelpers are really confusing and will probably be deprecated in the future.

mbrodala commented 1 month ago

As a first step making f:comment like expected and described here would likely help. Evidently "disabling the compiler" also is not enough, since we'd actually need a "disable the parser" flag.

lolli42 commented 1 month ago

Yes. We're deep in the parser here.

The current "solution" is documented in f:comment: <f:comment><![CDATA[<f:some.invalid.syntax />]]></f:comment>. Wrap the content in CDATA works. Reason: The NamespaceDetectionTemplateProcessor removes any CDATA wrapped content in an early step, before everything else is fed to the parser.

CDATA is of course ugly and it requires this manual interaction.

I think fluid has currently no solution to "stop" parsing sub elements.

And it gets worse: ext:styleguide has this usecase: It has a code viewhelper that should output html. If that code contains fluid VH's, those are interpreted - similar to the f:comment scenario. The CDATA "solution" does not work here, since the entire content vanishes ...

What we would need is a registry of VH's, to tell the parser if a VH is used in a template, the template parsing should stop. It looks as if this requires to make the regex $SPLIT_PATTERN_TEMPLATE_DYNAMICTAGS more dynamic, so fluid splits these parts differently on parser level. Such a change will require a bit of refactoring and a good solution for the registry. Not simple, and there may be more pressing issues.

Current ext:styleguide solution: html encode < and > and decode in VH again ...

lolli42 commented 1 month ago

Related: #808, #474, #346

lolli42 commented 1 month ago

There is also {parsing off} to stop parsing an entire template, see #219 (does not help us here, but this is yet another approach)

s2b commented 2 weeks ago

This will be possible with Fluid v4, the change has just been merged.