summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorBaptiste Mispelon <bmispelon@gmail.com>2013-11-06 00:17:28 +0100
committerBaptiste Mispelon <bmispelon@gmail.com>2013-11-06 00:26:58 +0100
commitb914991b3705cb6c91013d962c55cda9deb18d83 (patch)
tree702b997c0951bc36dafbf89ecd8c94679fce1427 /docs
parentc349bcbdf9c3520a0050bddf49ea59d9418c3ecb (diff)
Added more tests and documentation for dictsort.
It's possible to use something like {{ foo|dictsort:'bar.baz' }} but this wasn't tested or documented.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/templates/builtins.txt21
1 files changed, 21 insertions, 0 deletions
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
index 48412239ad..d8f76dc680 100644
--- a/docs/ref/templates/builtins.txt
+++ b/docs/ref/templates/builtins.txt
@@ -1433,6 +1433,27 @@ then the output would be:
{'name': 'zed', 'age': 19},
]
+You can also do more complicated things like::
+ {{ for book in books|dictsort:"author.age"
+ * {{ book.title }} ({{ book.author.name }})
+ {% endfor %}
+
+If ``books`` is:
+
+.. code-block:: python
+
+ [
+ {'title': '1984', 'author': {'name': 'George', 'age': 45}},
+ {'title': 'Timequake', 'author': {'name': 'Kurt', 'age': 75}},
+ {'title': 'Alice', 'author': {'name': 'Lewis', 'age': 33}},
+ ]
+
+the the output would be::
+
+ * Alice (Lewis)
+ * 1984 (George)
+ * Timequake (Kurt)
+
.. templatefilter:: dictsortreversed
dictsortreversed