Answers for "twig ternary"

PHP
1

twig ternary

/* Twig Ternary */
{{  var == 'value1' ? 'true output' : 'false output' }}
/* Twig If */
{% if var == 'value1' %}
	{{ do_this }}
{% elseif var == 'value2' %}
	{{ do_this }}
{% else %}
	{{ do_this }}
{% endif %}
/* Twig Set Var */ 
{% set var = 'value' %}
Posted by: Guest on August-05-2021
1

twig if ternary check

{{ foo ?: 'no' }} is the same as {{ foo ? foo : 'no' }}
{{ foo ? 'yes' }} is the same as {{ foo ? 'yes' : '' }}
Posted by: Guest on June-03-2021

Browse Popular Code Answers by Language