mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #34577 -- Added escapeseq template filter.
This commit is contained in:
parent
98f6ada0e2
commit
061a8a1bd8
5 changed files with 91 additions and 1 deletions
|
@ -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``
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue