Skip to content

[FEATURE] Introduce argument definitions for templates and partials#1063

Merged
s2b merged 1 commit intomainfrom
feature/templateArguments
May 12, 2025
Merged

[FEATURE] Introduce argument definitions for templates and partials#1063
s2b merged 1 commit intomainfrom
feature/templateArguments

Conversation

@s2b
Copy link
Contributor

@s2b s2b commented May 2, 2025

The new <f:argument> ViewHelper allows to define an API
for templates, partials and layouts that will be validated when
the template/partial/layout is rendered. For each argument,
a type can be defined. By default, arguments are defined as
non-optional, but they can be defined as optional by using
optional="{true}". Optional arguments can have default
values, which are defined with default="my default value".

To avoid unnecessary complexity, the ViewHelper ensures that
no dynamic content (like variables) can be used in an argument
definition. Also, <f:argument> can't be nested into other
ViewHelpers.

Template argument definitions are processed and verified
by the new StrictArgumentProcessor, which properly
ensures argument types by casting scalar values and checking
the types more thoroughly than the LenientArgumentProcessor.
This means that currently template arguments are validated
in a different way than ViewHelper arguments, however
this will be resolved with Fluid v5.

Currently, there is no way to prohibit additional arguments
that are not defined with the <f:argument> ViewHelper,
however this might still be added in the future.

@s2b s2b added the components label May 2, 2025
@s2b s2b force-pushed the feature/templateArguments branch 2 times, most recently from 0cc6bdf to 9af58ae Compare May 2, 2025 19:42
@s2b s2b force-pushed the feature/templateArguments branch 3 times, most recently from e15bdf9 to b23659c Compare May 7, 2025 18:11
@s2b s2b changed the title Feature/template arguments [FEATURE] Introduce argument definitions for templates and partials May 7, 2025
@s2b s2b force-pushed the feature/templateArguments branch 6 times, most recently from 096323f to ce52444 Compare May 7, 2025 19:00
@s2b s2b force-pushed the feature/templateArguments branch 3 times, most recently from 3d97700 to 5798cfb Compare May 7, 2025 19:25
@s2b s2b marked this pull request as ready for review May 7, 2025 19:25
@s2b s2b force-pushed the feature/templateArguments branch from 5798cfb to 060fabb Compare May 7, 2025 19:28
@s2b s2b force-pushed the feature/templateArguments branch from 060fabb to 456cdb7 Compare May 8, 2025 07:29
The new `<f:argument>` ViewHelper allows to define an API
for templates, partials and layouts that will be validated when
the template/partial/layout is rendered. For each argument,
a type can be defined. By default, arguments are defined as
non-optional, but they can be defined as optional by using
`optional="{true}"`. Optional arguments can have default
values, which are defined with `default="my default value"`.

To avoid unnecessary complexity, the ViewHelper ensures that
no dynamic content (like variables) can be used in an argument
definition. Also, `<f:argument>` can't be nested into other
ViewHelpers.

Template argument definitions are processed and verified
by the new `StrictArgumentProcessor`, which properly
ensures argument types by casting scalar values and checking
the types more thoroughly than the `LenientArgumentProcessor`.
This means that currently template arguments are validated
in a different way than ViewHelper arguments, however
this will be resolved with Fluid v5.

Currently, there is no way to prohibit additional arguments
that are not defined with the `<f:argument>` ViewHelper,
however this might still be added in the future.
@s2b s2b force-pushed the feature/templateArguments branch from 456cdb7 to acda79f Compare May 12, 2025 10:28
@s2b s2b merged commit af42319 into main May 12, 2025
8 checks passed
@s2b s2b deleted the feature/templateArguments branch May 12, 2025 11:50
@s2b s2b added this to the Community Budget Q2/2025 milestone May 20, 2025
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.

2 participants