Iterating over a dict in a jinja template

At the time of this posting, iterating over dictionaries inside a Jinja template is poorly documented, and it's something I end up doing alot. Here's how you do it, nice and simple...

<dl>
  {% for key, value in _dict.iteritems() %}
	<dt>{{ key }}</dt>
	<dd>{{ value }}</dd>
  {% endfor %}
</dl>

Easy after you know. See the full API: http://jinja.pocoo.org/docs/api/

Post A Twitter Response To This Blog Post

To: @mattccrampton

0