Check if string variable is null or empty, or full of white spaces

{% if your_variable is null or your_variable is empty %}

should check whether the variable is null or empty.

If you want to see if it’s not null or empty just use the notoperator.

 {% if foo is not null and foo is not empty %}

See the docs:

  • empty
  • null
  • “is” operator
  • logical operators like “not”

Perhaps you might be interested in tests in twig generally.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)