Skip to main content
3 of 3
added 7 characters in body
Selvin Ortiz
  • 1.6k
  • 11
  • 12

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: )

Selvin Ortiz
  • 1.6k
  • 11
  • 12