Fixing errors about undefined variables. Odd though, the solution
contradicts this: http://jinja.pocoo.org/docs/templates/#if