I know there was previous ticket about a json filter which came to the conclusion it was too hard to do a generic one that could be used everywhere [1] For the use case where the json is going to be in a script tag that won’t be executed it seems to me like the approach in django-argonauts is perfect.
Perhaps if we came up with a name that specified the context |escape_json_script or is that too much of a mouthful? [1] https://code.djangoproject.com/ticket/17419 <https://code.djangoproject.com/ticket/17419> > On 7 Oct 2015, at 01:57, Gavin Wahl <[email protected]> wrote: > > > Having looked around my solution is to output the json string with {{ > > json_string|escapejs }}. > > Then in the javascript call JSON.parse twice > > JSON.parse(JSON.parse('"' + jsonString + '"')); > > That doesn't seem nice at all. Is there any objection to putting the json > filter from django-argonauts into django? > > -- > You received this message because you are subscribed to the Google Groups > "Django developers (Contributions to Django itself)" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > Visit this group at http://groups.google.com/group/django-developers > <http://groups.google.com/group/django-developers>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/CACPudh203NvC8SY8wiDi5knpxyeOe9LB6HRn1s0P%3Dd%2BfQYyHkA%40mail.gmail.com > > <https://groups.google.com/d/msgid/django-developers/CACPudh203NvC8SY8wiDi5knpxyeOe9LB6HRn1s0P%3Dd%2BfQYyHkA%40mail.gmail.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/742638A3-B9C5-4156-B4E4-1105D893FA6C%40gmail.com. For more options, visit https://groups.google.com/d/optout.
