//EDIT
I am using standard template language, not jinja. Standard template language does not support a set
tag.
How can I declare a new variable using jinja?
The second line in the following code block result to an error:
{% set msg_class = "" %}
Error message:
Invalid block tag on line 13: 'set', expected 'elif', 'else' or 'endif'. Did you forget to register or load this tag?
Rest of the code:
{% if msg %}
{% set msg_class = "" %}
{% if status == 1 %}
{% set msg_class = "alert alert-success" %}
{% elif status == 3 %}
{% set msg_class = "alert alert-danger" %}
{% elif status == 4 %}
{% set msg_class = "alert alert-warning" %}
{% else %}
{% set status = 2 %}
{% set msg_class = "alert alert-info" %}
{% endif %}
{% endif %}
Using an array like in the following thread that I found, seems really ugly to me. Is it the only solution?
Can a Jinja variable's scope extend beyond in an inner block?