twig ternary

Solutions on MaxInterview for twig ternary by the best coders in the world

showing results for - "twig ternary"
Timothe
20 Nov 2017
1/* Twig Ternary */
2{{  var == 'value1' ? 'true output' : 'false output' }}
3/* Twig If */
4{% if var == 'value1' %}
5	{{ do_this }}
6{% elseif var == 'value2' %}
7	{{ do_this }}
8{% else %}
9	{{ do_this }}
10{% endif %}
11/* Twig Set Var */ 
12{% set var = 'value' %}
Flora
02 Feb 2020
1{{ foo ?: 'no' }} is the same as {{ foo ? foo : 'no' }}
2{{ foo ? 'yes' }} is the same as {{ foo ? 'yes' : '' }}
3