Opened 12 years ago
Closed 12 years ago
#19059 closed Uncategorized (wontfix)
New {% decode %} tag
Reported by: | Marc Rechté | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | 1.4 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hello,
I would really appreciate a standard "decode" tag that would do a value decoding. Syntax would be:
{% decode var value1 newvalue1 [value2 newvalue2...] [default_value] %}
Examples:
{% decode weather_forecast 'with' 'selected' %}
If weather_forecast equals 'with' return 'selected' else returns
{% decode category '12' '1' '13' '1', '14' '2' '0' %}
If category equals '12', '13' returns '1'
If category equals '14' returns '2'
Any other value returns '0'
Thanks
Change History (2)
follow-up: 2 comment:1 by , 12 years ago
Component: | Uncategorized → Template system |
---|
comment:2 by , 12 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Thanks for your submission
This kind of logic can be better handled by:
as your second example shows - the kwargs-as-a-list syntax gets very hard to follow
also, decode has several other meanings which would lead to ambiguity - but regardless of the name chosen - the functionality doesn't really warrant a new builtin tag.