#33405: Documentation for template filter 'escapejs' is extremely unclear
-------------------------------+--------------------------------------
Reporter: Jon Ribbens | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: 4.0
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Carlton Gibson):
* cc: Adam Johnson (added)
* status: new => closed
* resolution: => invalid
Comment:
Hi Jon.
Answering your last question first, generally it's not safe, and you
shouldn't do this. `escapejs` is just to put put escape sequences into
strings.
You want to look into the newer
[https://docs.djangoproject.com/en/3.2/ref/templates/builtins/#json-script
json_script] tag.
[https://adamj.eu/tech/2020/02/18/safely-including-data-for-javascript-
in-a-django-template/ Adam Johnson has a good post of this topic a while
back].
I'm going to close, as I think the text is OK... **but** happy to look at
concrete suggestions.
(I also wonder if we might not deprecate `escapejs` as of questionable
value, but perhaps that needs some discussion...)
--
Ticket URL: <https://code.djangoproject.com/ticket/33405#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.6ace49456778501254fc9f10a6dc46e1%40djangoproject.com.