#17419: Add a JSON template filter
-------------------------------------+-------------------------------------
Reporter: Lau Bech Lauritzen | Owner: Aymeric
| Augustin
Type: New feature | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: json template tag | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by blighj):
Seemed like a good idea at the time. If you had a variable that was
already json it would give you a simple way to wrap it in a script block.
If for what ever reason you had the following string passed to your
template
'{"variable":"user contributed string</script>"}'
which you wanted to output to javascript in a similar style, the filter
would be useful to output in a script safely but keeping it as json
What I hadn't considered was your simple string example or equally, if
someone did to_json("4"). They will expect that to be output as a string
not a number.
So yeah let's get rid of that idea, if someone has a json string and want
to use this filter, then call json.loads first.
Any other comments or advice?
--
Ticket URL: <https://code.djangoproject.com/ticket/17419#comment:37>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/061.4cf65e19cb318e2e5de76c97856cdc51%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.