Closed benjaminkott closed 4 months ago
Nice, I like that "separatorLast" argument!
It would be cool to have a property
argument, so when you provide an array of objects/arrays like {data.categories} then you can map it to a specific property like title
.
<f:split value="{data.categories}" property="title" separator=", "/>
There seem to be very different opinions about features like this (add to join VH vs. add a separate VH). I would suggest to add the VH as-is in the first step and to extend it afterwards if it's general consensus to go this route.
Seems to be a useful ViewHelper and will be happy to use it. I'd rather have named it ImplodeViewHelper for that's what it is actually called in PHP, but that's just me.
Nevertheless I'd like to ask why the class has to be final? I've just checked and it seems that only a minority of ViewHelpers are declared final - for whatever reason even. It'd be quite convenient if we could extend this or any other ViewHelper for that matter.
Nevertheless I'd like to ask why the class has to be final? I've just checked and it seems that only a minority of ViewHelpers are declared final - for whatever reason even. It'd be quite convenient if we could extend this or any other ViewHelper for that matter.
See e.g. https://matthiasnoback.nl/2018/09/final-classes-by-default-why/
In a perfect Fluid world each viewhelper is tiny and does a single thing, thus is atomic. Extending these wouldn't make sense in the first place and would also lead to tight coupling which would make changes to Fluid itself harder.
The JoinViewHelper combines elements from an array into a single string. You can specify both a general separator and a special one for the last element that is rendered between the elements.
Examples
Simple join
Results in the output:
Join with separator
Results in the output:
Join with separator, and special one for the last
Results in the output: