kurztipp
(Peter Kurz)
November 9, 2016, 1:35pm
#1
Hi,
is there an inline notation for <f:cycle> ViewHelper? I didn’t found anything in the manual. May it just isn’t documented? It would be helpful if you only want to output a singe variable at one specific place within a for loop depending on the cycle.
Regards
bwaidelich
(Bastian Waidelich)
November 23, 2016, 8:26am
#2
Hi,
the inline notation is not a feature that needs to be supported by ViewHelpers, it’s Fluid core functionality and the syntax goes like this:
Tag-based
<f:some.viewHelper someSimpleValue="123" someObject="{foo}" someString="{bar} {baz}" />
Inline notation
{f:some.viewHelper(someSimpleValue: 123, someObject: foo, someString: '{bar} {baz}')}
So, the example of the cycle ViewHelper (<f:cycle values="{0: 'foo', 1: 'bar', 2: 'baz'}" as="cycle">{cycle}</f:cycle>
) can be written as
{f:cycle(values: '{0: \'foo\', 1: \'bar\', 2: \'baz\'}', as: 'cycle')}
But that doesn’t really make sense because only the child nodes will be rendered and the inline notation only supports
{someVariable -> f:some.viewHelper()}
not
{'some string' -> f:some.viewHelper()}
For this you can use the iteration argument of the for
ViewHelper:
<f:for each="{items}" as="{item}" iteration="iteration">
{f:if(condition: iteration.isLast, then: ' last item!')}
</f:for>
HTH