Answers for "twig test check if variable exists"

3

twig is set variable

{# 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

Code answers related to "twig test check if variable exists"

Browse Popular Code Answers by Language