TWIG: is defined and is not null

Wrong

{% if var is not null and var is defined %}

This does not work because a variable which is null in twig is defnied, but if you check for null first and it is not defined it will throw an error.

Correct

{% if var is defined and var is not null %}

This will work because we check if it is defined first and will abord when not. Only if the variable is defined we check if it is null.

Leave a Comment

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