in a jinja2 for loop, how can I keep track of what the previous value of a variable was (for purposes of displaying breaks between "groups")? The obvious and straight-forward answer of:
{% set last_val='unk' %}
{% for object in data %}
{% if object[0]!=last_val %}
<output whatever separation code>
{% set last_val=object[0] %}
{% endif %}
<other stuff>
{% endfor %}
...doesn't work due to jinja2's scoping rules - each new time through the loop sees the same 'unk'. How can I work around this limitation?
EDIT: I was poking around some older code of mine where I had done similar things, and apparently this DID work with jinja2 2.8, but broke sometime before 2.9.6. So I guess one solution would be to downgrade to 2.8 and just stay there.