Fluid icon indicating copy to clipboard operation
Fluid copied to clipboard

Feature Request: null coalescing operator in inline fluid

Open CDRO opened this issue 5 years ago • 3 comments

I recently stumbled upon a fluid template that made me very sad and so I decided to improve it even more and after I was a little less sad I became a bit sadder nonetheless, because PHP has spoiled me with the null coalescing operator.

What I had:

<span><f:if condition="{model.field}"><f:then>{model.field}</f:then><f:else>Default</f:else></f:if>

What I hoped for:

<span>{model.field ?? 'Default'}</span>

It would be nice to have this feature in Fluid 3 (and even 2, but I guess we should slowly EOL it and push Fluid 3)

CDRO avatar Sep 02 '20 13:09 CDRO

I also would welcome support for a null coalescing shorthand syntax

da-anda avatar Oct 26 '21 11:10 da-anda

I started working on it, the reference tree is here:

https://github.com/CDRO/Fluid/tree/feature/nullcoalescing

It is still WIP, but I'll try to get it to work quickly so I can have it reviewed.

CDRO avatar Oct 26 '21 12:10 CDRO

#572

s2b avatar Nov 24 '23 17:11 s2b