?:
)Support for the extended ternary operator was added in Twig 1.12.0.
{{ foo ? 'yes' : 'no' }}
Evaluates:
if
foo
echoyes
else echono
{{ foo ?: 'no' }}
or
{{ foo ? foo : 'no' }}
Evaluates:
if
foo
echo it, else echono
{{ foo ? 'yes' }}
or
{{ foo ? 'yes' : '' }}
Evaluates:
if
foo
echoyes
else echo nothing
??:
){{ foo ?? 'no' }}
Evaluates:
Returns the value of
foo
if it is defined and not null,no
otherwise