[TYPO3-mvc] Viewhelper arguments in shorthands

Sebastian Kurfürst sebastian at typo3.org
Mon Oct 26 12:56:00 CET 2009


Hey Sebastian,


> Playing around with shorthands i recognized that values as viewhelper
> arguments are wrapped in {} curly braces.
> In shorthands they are used without curly braces.
Yes! This is the way we thought it should be.

In XML ViewHelpers, the attributes (of course) need to be wrapped into
{}, so to distinguish them. And because it is XML, you _have to_ quote
all arguments.

The shorthand syntax is an alternative, which has a somewhat different
paradigm:
- access some ViewHelpers which are mostly standalone or postprocessors
of values
- make chaining easy
- with a short / concise syntax

In the first version of the shorthand syntax you needed to quote
everything, thus you had stuff like: {s:myviewhelper(attrib="{bla}")}
which became actually quite confusing.
We then thought a lot about "cleaning" the syntax, and are now using
another paradigm: The array paradigm.
All ViewHelper parameters are stated exactly as arrays are defined in
Fluid (and JSON).

> {s:myviewhelper(attribname: "fixedvalue somevalue")}
This would never work, as one could not distinguish between variables
and non-variables.

> {s:myviewhelper(attribname: "fixedvalue {somevalue}")}
We could make this work (this would be a bit more consistent at least),
but so far our feeling is that this is what you call a "bad smell" in
software engineering - a feeling that something might be missing at
other parts of your system. So you should enrich your model maybe,
provide a special getter for "{firstname} {lastname}" or hand over two
separate values to your ViewHelper if it makes sense to you.

> In both cases additional braces would help i think/hope.
We wanted to get rid of these, exactly :-)

Hope I could clarify the ideas a bit more.

Greets,
Sebastian


More information about the TYPO3-project-typo3v4mvc mailing list