Suggestion #5948
join
Status: | New | Start date: | 2010-01-10 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | - | % Done: | 0% |
|
Category: | - | |||
Target version: | - | |||
Has patch: | Tags: |
Description
Sometimes you want to concatenate elements as a comma separated list. Or maybe you want to put the elements in different lines by <br>.
The attached file implements this feature:
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>
The necessary "item" and "by" view helpers are similar to "then" and "else".
History
#1 Updated by Martin Kutschker over 5 years ago
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"
#2 Updated by Bastian Waidelich about 5 years ago
- Tracker changed from Feature to Suggestion
- Project changed from TYPO3.Fluid to Fluid - ViewHelper - Incubator
#3 Updated by Bastian Waidelich about 5 years ago
- Subject changed from an implode/join view helper for convenience to join