The first statement checks for the existence of var
, the second checks that it has a value other than null
and will throw and error if var
does not exist.
If you're not sure whether a variable exists, you should check if it exists first then check for its value to be safe.
You could combine both statements like so {% if var is defined and var is not null %}
or use empty, not empty
if you're feeling fancy: )