Open dAnjou opened 6 months ago
Good point about at least adding that to the docs!
My hacky workaround for this was something like:
class FakeLoop:
last = True
return render_block(file, fragment, loop=FakeLoop())
but I didn't have anything complex and only needed that one attribute.
Hi,
I'm migrating a traditional Flask+Jinja2 app to one with HTMX. Similar to #23, I'm using a block inside a loop.
I'm also using the special
loop.index
variable, which is when I'm getting:jinja2.exceptions.UndefinedError: 'loop' is undefined
.I know I can get around that by simply wrapping my iterable into
list(enumerate(...))
, but it'd probably make a smoother experience ifloop
was available.Not sure if that's even possible. If not, it should probably be documented as a caveat.
🙏