For this example, with no default value, it even might be cool to have an IF object like the <f:if> Viewhelper in fluid. on the other hand, there might be a reason, why it was not implemented yet.
Problem is that the path content is added on two levels. The second one inside the matcher can be circumvented via @children=renderer but there is no such sytax that adds afx children as properties to the parent object directly which would be required for the Neos.Fusion:Case so unless we come up with a smart solution for that afx will not work with Case (yet)
@mficzel Thank you for diving into it. I’ll try to think about a smart solution…
Is there an easy way to display the fusion code that is generated by afx? Or did you just do it by hand?
@benjamink yes, it’s definitely easier to read, when the @if is in a seperate line. But I still think there should be a dedicated fusion object for it.
im not so sure if this should be a native feature, as the @if thing is specifically made for this reason… and then there would be two ways to handle one thing. otherwise there is no @for meta attribute but one needs to use Neos.Fusion:Loop - seems a bit inconsistend…
technically this is working, really ugly and not recommendet:
and i dont know if we should add a @directChildItems='true' for afx customization to avoid the Join. (Since we have already @path and @children and those are somewhat not so cool ^^)
I found a pattern based on the Neos.Fusion:Match prototype that is very similar to the request above. The only limitation is that the discriminator has to be a valid fusion path.
prototype(YourVendor:FusionPrototype) < prototype(Neos.Fusion:Component) {
discriminator = "foo"
renderer = afx`
<Neos.Fusion:Match @subject={props.discriminator} >
<Neos.Fusion:Fragment @path="foo">
case foo
</Neos.Fusion:Fragment>
<Neos.Fusion:Fragment @path="bar">
case bar
</Neos.Fusion:Fragment>
<Neos.Fusion:Fragment @path="@default">
default
</Neos.Fusion:Fragment>
</Neos.Fusion:Match>
`
}