Opened 14 years ago
Closed 14 years ago
#17348 closed New feature (fixed)
Implement {% elif %} in the template language
| Reported by: | Aymeric Augustin | Owned by: | Aymeric Augustin |
|---|---|---|---|
| Component: | Template system | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | mmitar@… | Triage Stage: | Accepted |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Following a discussion on IRC today, this feature is deemed useful by some, but others think it add too much logic in the templates.
#3100 may be related.
Attachments (1)
Change History (7)
comment:1 by , 14 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|---|
| Version: | → SVN |
comment:2 by , 14 years ago
| Cc: | added |
|---|
comment:3 by , 14 years ago
@aaugustin -- Count me as +1 on this; I can't see any argument where massively nested ifs are preferable to a flat series of {% elif %} statements. I don't think this increases the amount of logic in a template; it just makes the logic that we've already allowed slightly more friendly.
comment:4 by , 14 years ago
| Owner: | changed from to |
|---|
comment:5 by , 14 years ago
Attached patch implements {% elif %}. It complements 3100-backwards-compatible.patch from #3100.
by , 14 years ago
| Attachment: | 17348.patch added |
|---|
#3100 is about supporting arguments on intermediate tag tokens, and it's a pre-requisite for this ticket.
Here are the arguments I saw on IRC.
Pros:
{% if a %} ... {% else %}{% if b %} ... {% else %}{% if c %} ... {% endif %}{% endif %}{% endif %}{% include myobj.state_template %}where state_template returns"partials/state_<STATE>.html", but that's overkill for simple casesCons:
Tentatively marking as accepted, please bump back to DDN if you disagree.