In Jinja2 templates, it is often a good practice to test if a variable exists and what value does it carry.
There are several useful tests that you can make using Jinja2 builtin tests and filers.
In this article, i’ll show how to test if a variable exists or not, if it is empty or not and if it is set to True.
I’ll also give two examples of how to combine these checks. (more…)