From 0ee03a439b7016c068ab2e0c477d5c84f750a82c Mon Sep 17 00:00:00 2001 From: Hrushikesh Vaidya Date: Tue, 28 Jun 2022 10:30:39 +0200 Subject: [PATCH] Refs #33779 -- Doc'd django.utils.html.json_script(). --- docs/ref/utils.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt index 77120159295..6b44e81611f 100644 --- a/docs/ref/utils.txt +++ b/docs/ref/utils.txt @@ -655,6 +655,20 @@ escaping HTML. ((u.first_name, u.last_name) for u in users) ) +.. function:: json_script(value, element_id=None) + + Escapes all HTML/XML special characters with their Unicode escapes, so + value is safe for use with JavaScript. Also wraps the escaped JSON in a + ``' + + .. versionchanged:: 4.1 + + In older versions, the ``element_id`` argument was required. + .. function:: strip_tags(value) Tries to remove anything that looks like an HTML tag from the string, that