{% set active = true %}
{% for i in range(3) %}
{% if i == 1 %}
{% set active = false %}
{% endif %}
{{ active }}
{% endfor %}
The output is:
True
False
True
How can the value active change back to True. Maybe it is the initial value, but I need the boolean to be valid during the loop. This is probably me making a simply mind mistake.
that is because the attrib is not maintained in the for loop…try this
{% set ns=namespace(x=true) %}
{% set active = true %}
{% for i in range(3) %}
{% if i == 1 %}
{% set ns.x = false %}
{% endif %}
{% endfor %}
{{ ns.x }}