Feature #33817
SwitchViewHelper
| Status: | Under Review | Start date: | 2012-02-09 | |
|---|---|---|---|---|
| Priority: | Could have | Due date: | ||
| Assignee: | Bastian Waidelich | % Done: | 0% |
|
| Category: | ViewHelpers | |||
| Target version: | - | |||
| Has patch: | No | |||
| Votes: | 0 |
Description
Fluid should provide a Switch VH that behaves like the well-known switch-case structure.
Syntax suggestion:
<f:switch comparand="{foo.bar}">
<f:switch.case comparand="valuecase1">
<span>Output in this case.</span>
</f:switch.case>
<f:switch.case comparand="nothervaluecase">
<a>Output in another case.</a>
</f:switch.case>
<f:switch.case comparand="third">
<a>Output in another case.</a>
</f:switch.case>
<f:switch.default>
Default value if nothing else matches.
</f:switch.default>
</f:switch>
There's an already present implementation here: http://fedext.net/fed-viewhelpers/loops-conditions/switch/ but tbh I at least don't agree with the "default" implementation because it could collide with the value being "default" as string:
<fed:switch value="{switchValue}">
<fed:case case="1">
<p>Case was 1</p>
</fed:case>
<fed:case case="default">
<p>Case was default</p>
</fed:case>
</fed:switch>
History
Updated by Adrian Föder over 1 year ago
additionally, I would prefer dropping "break" support because its use is also pretty ugly in "real" situations imho.
Updated by Bastian Waidelich over 1 year ago
- Status changed from New to Accepted
- Assignee set to Bastian Waidelich
Hi, that's already on my (longish) todo list. I agree with your two points on the magic "default" and break.
Updated by Bastian Waidelich about 1 year ago
- File SwitchViewHelper.php added
- File CaseViewHelper.php added
Attached a first version that works in general but has side effects when used nested - so it still needs some adjustments
Updated by Gerrit Code Review 6 days ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/20787