docs: Added example to show use of forloop.xin a for loop (#123)

This commit is contained in:
Ian Dundas
2017-07-12 11:46:43 +02:00
committed by Kyle Fuller
parent e217a9c873
commit 793773f191

View File

@@ -59,6 +59,23 @@ The for block sets a few variables available within the loop:
- ``last`` - True if this is the last time through the loop
- ``counter`` - The current iteration of the loop
For example:
.. code-block:: html+django
{% for user in users %}
{% if forloop.first %}
This is the first user.
{% endif %}
{% endfor %}
.. code-block:: html+django
{% for user in users %}
This is user number {{ forloop.counter }} user.
{% endfor %}
``if``
~~~~~~