Opened 20 months ago

Closed 20 months ago

Last modified 20 months ago

#21747 closed Cleanup/optimization (fixed)

The {% elif %} templatetag could use documentation

Reported by: gcc Owned by: nobody
Component: Documentation Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The Django templates page makes no mention of the {% elif %} tag, although it does document {% if %} and {% else %}.

I was curious so I went digging in the source, and discovered that {% elif %} is implemented. It even has doc comments:

{% if athlete_list %}
    Number of athletes: {{ athlete_list|count }}
{% elif athlete_in_locker_room_list %}
    Athletes should be out of the locker room soon!
{% else %}
    No athletes.
{% endif %}

It would be great to have it officially documented on the Templates page.

Change History (3)

comment:1 Changed 20 months ago by mjtamlyn

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from New feature to Cleanup/optimization

The {% elif %} tag is documented as part of the {% if %} documentation in the reference docs: https://docs.djangoproject.com/en/dev/ref/templates/builtins/#ref-templates-builtins-tags

These are quite heavily linked to from the section you mention, but I guess it wouldn't hurt to amend one of the examples there to include an elif.

comment:2 Changed 20 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 9e5033b302676856901a7808910fcab5c3fe1d27:

Fixed #21747 -- Added {% elif %} to template topics guide.

Thanks gcc for the suggestion.

comment:3 Changed 20 months ago by Tim Graham <timograham@…>

In f8d93f2c71f5a6dff349ec290f9ca6d7d316ba4f:

[1.6.x] Fixed #21747 -- Added {% elif %} to template topics guide.

Thanks gcc for the suggestion.

Backport of 9e5033b302 from master

Note: See TracTickets for help on using tickets.
Back to Top