]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
do_dictsort: update example ready to copy/paste 1209/head
authorMark Hansen <markhansen@google.com>
Sat, 16 May 2020 07:07:59 +0000 (17:07 +1000)
committerGitHub <noreply@github.com>
Sat, 16 May 2020 07:07:59 +0000 (17:07 +1000)
When iterating over a dict you usually want to pull out the keys and values.

src/jinja2/filters.py

index 974156735123b88ed996997cf18e2db03bc3c7be..74b108dceca43905897ffc6dd8bdc0de23332ccc 100644 (file)
@@ -268,16 +268,16 @@ def do_dictsort(value, case_sensitive=False, by="key", reverse=False):
 
     .. sourcecode:: jinja
 
-        {% for item in mydict|dictsort %}
+        {% for key, value in mydict|dictsort %}
             sort the dict by key, case insensitive
 
-        {% for item in mydict|dictsort(reverse=true) %}
+        {% for key, value in mydict|dictsort(reverse=true) %}
             sort the dict by key, case insensitive, reverse order
 
-        {% for item in mydict|dictsort(true) %}
+        {% for key, value in mydict|dictsort(true) %}
             sort the dict by key, case sensitive
 
-        {% for item in mydict|dictsort(false, 'value') %}
+        {% for key, value in mydict|dictsort(false, 'value') %}
             sort the dict by value, case insensitive
     """
     if by == "key":