mirror of
https://github.com/django/django.git
synced 2024-11-29 14:46:18 +01:00
Fixed #21747 -- Added {% elif %} to template topics guide.
Thanks gcc for the suggestion.
This commit is contained in:
parent
34490792f1
commit
9e5033b302
@ -211,18 +211,23 @@ tags:
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
:ttag:`if` and ``else``
|
:ttag:`if`, ``elif``, and ``else``
|
||||||
Evaluates a variable, and if that variable is "true" the contents of the
|
Evaluates a variable, and if that variable is "true" the contents of the
|
||||||
block are displayed::
|
block are displayed::
|
||||||
|
|
||||||
{% if athlete_list %}
|
{% if athlete_list %}
|
||||||
Number of athletes: {{ athlete_list|length }}
|
Number of athletes: {{ athlete_list|length }}
|
||||||
|
{% elif athlete_in_locker_room_list %}
|
||||||
|
Athletes should be out of the locker room soon!
|
||||||
{% else %}
|
{% else %}
|
||||||
No athletes.
|
No athletes.
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
In the above, if ``athlete_list`` is not empty, the number of athletes
|
In the above, if ``athlete_list`` is not empty, the number of athletes
|
||||||
will be displayed by the ``{{ athlete_list|length }}`` variable.
|
will be displayed by the ``{{ athlete_list|length }}`` variable. Otherwise,
|
||||||
|
if ``athlete_in_locker_room_list`` is not empty, the message "Athletes
|
||||||
|
should be out..." will be displayed. If both lists are empty,
|
||||||
|
"No athletes." will be displayed.
|
||||||
|
|
||||||
You can also use filters and various operators in the :ttag:`if` tag::
|
You can also use filters and various operators in the :ttag:`if` tag::
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user