From b65fce659502ac5e211d13fbd5435e1ff6c703d2 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Tue, 4 Dec 2007 21:08:29 +0000 Subject: Fixed #4131: added an "escapejs" filter for use in JavaScript strings, and updated the documentation on addslashes to point to the new ticket. Featuring contributions from Ned Batchelder, Jeremy Dunck, and Andy Durdin. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6892 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/templates.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/templates.txt b/docs/templates.txt index e91d1b3e4c..3b38caf58b 100644 --- a/docs/templates.txt +++ b/docs/templates.txt @@ -1227,8 +1227,10 @@ Adds the arg to the value. addslashes ~~~~~~~~~~ -Adds slashes. Useful for passing strings to JavaScript, for example. +Adds slashes before quotes. Useful for escaping strings in CSV, for example. +**New in Django development version**: for escaping data in JavaScript strings, +use the `escapejs` filter instead. capfirst ~~~~~~~~ @@ -1302,6 +1304,15 @@ applied to the result will only result in one round of escaping being done. So it is safe to use this function even in auto-escaping environments. If you want multiple escaping passes to be applied, use the ``force_escape`` filter. +escapejs +~~~~~~~~ + +**New in Django development version** + +Escapes characters for use in JavaScript strings. This does *not* make the +string safe for use in HTML, but does protect you from syntax errors when using +templates to generate JavaScript/JSON. + filesizeformat ~~~~~~~~~~~~~~ -- cgit v1.3