Opened 16 years ago

Closed 16 years ago

#9701 closed (fixed)

A safelist filter ("safe" for lists)

Reported by: Malcolm Tredinnick Owned by: Malcolm Tredinnick
Component: Template system Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Right now, there's no way for a template designer to indicate that each element in a variable that's a list is "safe" for autoescaping purposes. Using the safe filter would treat the list as a string. For example, as reasonable workaround to #9700 might be to be able to write

{{ some_list|safelist|join:", " }}

Might be worth adding this.

Change History (4)

comment:1 by Malcolm Tredinnick, 16 years ago

Triage Stage: UnreviewedDesign decision needed

comment:2 by Daniel Pope <dan@…>, 16 years ago

More generally, perhaps a map filter or tag? I can imagine

{% map safe over some_list as safe_list %}
{{safe_list|join:", "}}

covering more situations, especially if it's lazy.

comment:3 by Malcolm Tredinnick, 16 years ago

No, I'm intentionally not going for anything map-like. Templates are not a programming language.

comment:4 by Malcolm Tredinnick, 16 years ago

Resolution: fixed
Status: newclosed

(In [9952]) Fixed #9701 -- Added a "safeseq" template filter.

This is like "safe", except it operates on the individual elements of a
sequence, rather than treating the whole argument as a string.

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