Answers for "twig variable if"

3

if variable is defined twig

{# defined works with variable names #}
{% if foo is defined %}
    ...
{% endif %}

{# and attributes on variables names #}
{% if foo.bar is defined %}
    ...
{% endif %}

{% if foo['bar'] is defined %}
    ...
{% endif %}
Posted by: Guest on February-11-2020
0

twig and conditional operator

{% if 1 > 2 and 3 == 3 %}
{% endif %}
Posted by: Guest on June-25-2021

Browse Popular Code Answers by Language