twig var is not defined code example
Example 1: twig variable is defined
{% if varname is defined %}
Variable exists.
{% endif %}
Example 2: twig variable is not defined
{% if not (varname is defined) %}
Variable does not exist.
{% endif %}
{% if varname is defined %}
Variable exists.
{% endif %}
{% if not (varname is defined) %}
Variable does not exist.
{% endif %}