-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] JoinViewHelper #861
Conversation
1ef153f
to
cc010eb
Compare
cc010eb
to
990311e
Compare
Nice, I like that "separatorLast" argument! |
b9ea6cd
to
cdc6998
Compare
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. ```html <f:join value="{0: '1', 1: '2', 2: '3'}" /> ``` Results in the output: ```html 123 ``` ```html <f:join value="{0: '1', 1: '2', 2: '3'}" separator=", " /> ``` Results in the output: ```html 1, 2, 3 ``` ```html <f:join value="{0: '1', 1: '2', 2: '3'}" separator=", " separatorLast=" and " /> ``` Results in the output: ```html 1, 2 and 3 ```
cdc6998
to
d022511
Compare
It would be cool to have a
|
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. |
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: