summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorjeff <jeff@sixtyfathoms.com>2020-06-13 13:30:27 -1000
committerDavid Lord <davidism@gmail.com>2021-04-05 14:17:01 -0700
commit0fa20045b0d2bf06f11a2bab005d9bd986525eda (patch)
tree01f332e2019c2c6a01956b5c387eebf3e137e739 /docs
parent4abb2a0739195c697751f734d084d76272d12359 (diff)
downloadjinja2-0fa20045b0d2bf06f11a2bab005d9bd986525eda.tar.gz
update wording on dictionary default ordering
Diffstat (limited to 'docs')
-rw-r--r--docs/templates.rst14
1 files changed, 11 insertions, 3 deletions
diff --git a/docs/templates.rst b/docs/templates.rst
index 6226468..1826bbc 100644
--- a/docs/templates.rst
+++ b/docs/templates.rst
@@ -688,9 +688,17 @@ iterate over containers like `dict`::
{% endfor %}
</dl>
-Note, however, that **Python dicts are not ordered**; so you might want to
-either pass a sorted ``list`` of ``tuple`` s -- or a
-``collections.OrderedDict`` -- to the template, or use the `dictsort` filter.
+Python dicts may not be in the order you want to display them in. If
+order matters, use the ``|dictsort`` filter.
+
+.. code-block:: jinja
+
+ <dl>
+ {% for key, value in my_dict | dictsort %}
+ <dt>{{ key|e }}</dt>
+ <dd>{{ value|e }}</dd>
+ {% endfor %}
+ </dl>
Inside of a for-loop block, you can access some special variables: