Opened 7 years ago

Closed 7 years ago

#9701 closed (fixed)

A safelist filter ("safe" for lists)

Reported by: mtredinnick Owned by: mtredinnick
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: UI/UX:

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 Changed 7 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 7 years ago by Daniel Pope <dan@…>

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 Changed 7 years ago by mtredinnick

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

comment:4 Changed 7 years ago by mtredinnick

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

(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