pwt.jinja2js icon indicating copy to clipboard operation
pwt.jinja2js copied to clipboard

Unable to use loop.index with other jinja variables.

Open rammie opened this issue 12 years ago • 0 comments

Hey, we love pwt.jinja2js. For some reason, the following template throws an error:

{% for item in lst %} {{ loop.index }} {{ item.name }} {% endfor %}

The following change fixes this issue: line 644 in jscompiler.py: if frame.forloop_buffer and node.node.name == "loop":

new line 644 in jscompiler.py: if frame.forloop_buffer and getattr(node.node, "name", None) == "loop":

I noticed that none of the tests attempt to use both the "loop" variables, and other variables within the same "for" tag. That might be why this never occurred before.

Ram

rammie avatar Feb 24 '13 06:02 rammie