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