Feature #77275
closed
Added by Daniel Corn almost 8 years ago.
Updated almost 8 years ago.
Description
I think it would be good to have an inverse version of the IfViewHelper.
For me the following workaround is not very pretty:
<f:if condition="{condition}">
<f:then> </f:then>
<f:else>This is the important part</f:else>
</f:if>
My suggestion is to introduce the UnlessViewHelper, like in [Handlebars](http://handlebarsjs.com/builtin_helpers.html#unless)
<f:unless condition="{hopeFullyFalse}">
Alright, the variable is false
</f:unless>
<f:unless condition="{hopeFullyFalse}">
<f:then>Alright, the variable is false</f:then>
<f:else>Sorry the variable is true</f:else>
</f:unless>
PS: Sorry if this is a duplicate
- Description updated (diff)
- Status changed from New to Needs Feedback
Hi!
- you can leave out the empty
<f:then>
- you can simply use a negated condition
{foo} == 0
Thank you for updating the description!
And thank you for your feedback! I wasn't aware that it's possible to leave the empty <f:then>
. Would solution 2 would also work for e.g. an empty array?
<f:if condition="{myArray}">
<f:else>Array is empty</f:else>
</f:if>
<f:if condition="{myArray -> f:count()} == 0">Array is empty</f:if>
Small hint: Please use Slack to ask for help before you open tickets. thanks.
On Slack I was suggested to open a ticket for feature requests.
IMHO the solutions are not optimal from a semantic perspective, but others may disagree.
Well, personally I dislike the "unless" stuff.
This is a feature only available in Ruby and other languages, but is not part of any of the major programming languages like C, C#, Java, etc.
IMO a developer should be able to simply negate a condition.
Fine with closing this?
(new basic viewhelpers like a f:unless should go into the standalone project anyway and not only into TYPO3 core)
Yes, feel free to close this.
Thank you for your feedback!
- Status changed from Needs Feedback to Closed
Thanks for the quick response
Also available in: Atom
PDF