summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJon Ribbens <jribbens@gmail.com>2023-05-25 16:39:15 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-07-03 12:32:58 +0200
commitadfb3dfa89b62ee0c838a64d3d480c03dd3ec869 (patch)
tree561a534bc5456cb4854829ac114969363379f580 /docs
parent075e9c0a4d56709fab1dd741f3bc9548c4419632 (diff)
Fixed #33405, Refs #7177 -- Clarified docs for filter escapejs regarding safe and unsafe usages.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/templates/builtins.txt15
-rw-r--r--docs/spelling_wordlist1
2 files changed, 9 insertions, 7 deletions
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
index 9c7a8b63bb..65579677ca 100644
--- a/docs/ref/templates/builtins.txt
+++ b/docs/ref/templates/builtins.txt
@@ -1877,18 +1877,19 @@ For example, you can apply ``escape`` to fields when :ttag:`autoescape` is off:
``escapejs``
------------
-Escapes characters for use in JavaScript strings. This does *not* make the
-string safe for use in HTML or JavaScript template literals, but does protect
-you from syntax errors when using templates to generate JavaScript/JSON.
+Escapes characters for use as a whole JavaScript string literal, within single
+or double quotes, as below. This filter does not make the string safe for use
+in *"JavaScript template literals"* (the JavaScript backtick syntax). Any other
+uses not listed above are not supported. It is generally recommended that data
+should be passed using HTML ``data-`` attributes, or the :tfilter:`json_script`
+filter, rather than in embedded JavaScript.
For example:
.. code-block:: html+django
- {{ value|escapejs }}
-
-If ``value`` is ``"testing\r\njavascript 'string\" <b>escaping</b>"``,
-the output will be ``"testing\\u000D\\u000Ajavascript \\u0027string\\u0022 \\u003Cb\\u003Eescaping\\u003C/b\\u003E"``.
+ <script>
+ let myValue = '{{ value|escapejs }}'
.. templatefilter:: escapeseq
diff --git a/docs/spelling_wordlist b/docs/spelling_wordlist
index 26d777ab68..bdcbac4793 100644
--- a/docs/spelling_wordlist
+++ b/docs/spelling_wordlist
@@ -40,6 +40,7 @@ backends
backport
backported
backports
+backtick
backtraces
balancer
basename