TYPO3 / Fluid

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

[TASK] Set content argument name explicitly in ViewHelpers #963

Closed s2b closed 2 months ago

s2b commented 2 months ago

CompileWithContentArgumentAndRenderStatic exists to simplify a common use case of ViewHelpers: A ViewHelper should be callable both with an argument and with its child content.

Example:

<f:variable name="myVar" value="my value" />
<f:variable name="myVar">my value</f:variable>

This can also be helpful with Fluid's inline syntax:

{f:format.json(value: myObject)}
{myObject -> f:format.json()}

While this feature is very useful, the trait also offers a more confusing feature: If the "content argument name" isn't defined explicitly, it will try to guess that name by going through all defined ViewHelper arguments and pick the first optional argument.

This is unnecessary magic behavior, which will be removed in the future. As preparation for that, we define the content argument name explicitly in all existing ViewHelpers that still use the automagic behavior.