[TYPO3-mvc] RFC: join view helper

Tomas Majer majer at monogram.sk
Thu Jan 14 19:34:29 CET 2010


Hi

Nice idea with join!

Before Fluid i used Smarty a I like funcions like: 
{$smarty.foreach.foo.iteration} or {$smarty.foreach.foo.first} etc.

i didnt find this in fluid, so i write helpers like for.first, 
for.notFirst, for.index.

example:

<f:for each="{values}" as="item">
	<ext:for.first each="{values}"> # </ext:for.first>
	<ext:for.index each="{values}" />.{item}
	<ext:for.notlast each="{values}">, </ext:for.notlast>
</f:for>

and output:

# 1.apple, 2.bannana


Tomaj


Dňa 9. 1. 2010 16:37, Martin Kutschker  wrote / napísal(a):
> Hi!
>
> I propose a view helper to join arrays in an easy way.
>
> Shortest possible syntax:
>
> <f:join each="{0: 'apple', 1: 'banana'}" by=" and " />
>
> Typical syntax:
>
> <f:join each="{0: 'apple', 1: 'banana'}" as="fruit" by=" and ">{fruit}</f:join><br>
>
> Long syntax:
>
> <f:join each="{0: 'apple', 1: 'banana'}" as="fruit">
>   <f:item>{fruit}</f:item>
>   <f:by>  and</f:by>
> </f:join>
>
> I have created a view helper for this syntax in my example extension "ballroom dancing".
>
> Perhaps an optional argument "lastBy" eases things even more:
>
> <f:join each="{0: 'apple', 1: 'banana', 2: 'mango'}" by=", " lastBy=" and " />
>
> Which would yield: "apple, banana and mango"
>
> Masi



More information about the TYPO3-project-typo3v4mvc mailing list