feat(for tag): Support where expressions (#96)

This commit is contained in:
Ilya Puchka
2017-04-11 12:39:00 +02:00
committed by Kyle Fuller
parent dc8759ba34
commit d1717df6ff
4 changed files with 60 additions and 16 deletions

View File

@@ -19,6 +19,17 @@ A for loop allows you to iterate over an array found by variable lookup.
{% endfor %}
</ul>
The ``for`` tag can contain optional ``where`` expression to filter out
elements on which this expression evaluates to false.
.. code-block:: html+django
<ul>
{% for user in users where user.name != "Kyle" %}
<li>{{ user }}</li>
{% endfor %}
</ul>
The ``for`` tag can take an optional ``{% empty %}`` block that will be
displayed if the given list is empty or could not be found.