sponsfreixes / jinja2-fragments

Render Jinja2 template block as HTML page fragments on Python web frameworks.
MIT License
245 stars 13 forks source link

accessing dictionary.items() is undefined #32

Closed gconklin closed 4 months ago

gconklin commented 4 months ago
my_dict = {"a": "apple", "b":  "bananna"}
return render_block(template, block, my_dict=my_dict)
{% block content %}
  {% for k, v in my_dict.items() %}
    {{ k }} = {{ v }}
  {% endfor %}
{% endblock %}

jinja2.exceptions.UndefinedError: 'my_dict' is undefined

The fix for #21 created this issue. Building the module when dictionary.items() is used raises an undefined exception because the variables were not present.

(likely a problem for any object.attribute access)