Opened 8 years ago

Closed 8 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



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] %}

{% 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'


Change History (2)

comment:1 Changed 8 years ago by Marc Rechté

Component: UncategorizedTemplate system

comment:2 in reply to:  1 Changed 8 years ago by Preston Holmes

Resolution: wontfix
Status: newclosed

Thanks for your submission

This kind of logic can be better handled by:

  • setting context in your view
  • the current if tag
  • a custom template tag

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.

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