diff options
| author | Arthur Moreira <moreirarthur96@gmail.com> | 2023-05-19 19:33:51 -0300 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-05-22 09:58:03 +0200 |
| commit | 061a8a1bd818ca2c8a6493f33cae2379e34e181f (patch) | |
| tree | 5f5ff4e46207725cf153dc38cb8001b0b969c7b1 /docs | |
| parent | 98f6ada0e2058d67d91fb6c16482411ec2ca0967 (diff) | |
Fixed #34577 -- Added escapeseq template filter.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/templates/builtins.txt | 19 | ||||
| -rw-r--r-- | docs/releases/5.0.txt | 3 |
2 files changed, 21 insertions, 1 deletions
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt index 3aa20dfc71..695357c5a0 100644 --- a/docs/ref/templates/builtins.txt +++ b/docs/ref/templates/builtins.txt @@ -1831,6 +1831,8 @@ For example, you can apply ``escape`` to fields when :ttag:`autoescape` is off: {{ title|escape }} {% endautoescape %} +To escape each element of a sequence, use the :tfilter:`escapeseq` filter. + .. templatefilter:: escapejs ``escapejs`` @@ -1849,6 +1851,23 @@ For example: If ``value`` is ``"testing\r\njavascript 'string\" <b>escaping</b>"``, the output will be ``"testing\\u000D\\u000Ajavascript \\u0027string\\u0022 \\u003Cb\\u003Eescaping\\u003C/b\\u003E"``. +.. templatefilter:: escapeseq + +``escapeseq`` +------------- + +.. versionadded:: 5.0 + +Applies the :tfilter:`escape` filter to each element of a sequence. Useful in +conjunction with other filters that operate on sequences, such as +:tfilter:`join`. For example: + +.. code-block:: html+django + + {% autoescape off %} + {{ my_list|escapeseq|join:", " }} + {% endautoescape %} + .. templatefilter:: filesizeformat ``filesizeformat`` diff --git a/docs/releases/5.0.txt b/docs/releases/5.0.txt index 611a7bd68b..e6526dd798 100644 --- a/docs/releases/5.0.txt +++ b/docs/releases/5.0.txt @@ -345,7 +345,8 @@ Signals Templates ~~~~~~~~~ -* ... +* The new :tfilter:`escapeseq` template filter applies :tfilter:`escape` to + each element of a sequence. Tests ~~~~~ |
