#17419: JSON template tag
---------------------------------+-------------------------------
     Reporter:  lau              |      Owner:  nobody
         Type:  New feature      |     Status:  new
    Component:  Template system  |    Version:  1.3
     Severity:  Normal           |   Keywords:  json template tag
 Triage Stage:  Unreviewed       |  Has patch:  1
Easy pickings:  0                |      UI/UX:  0
---------------------------------+-------------------------------
 It's nice to be able to quickly make Python lists and dictionaries into
 JSON. The normal way of doing this is to dump the data structure as JSON
 in the view and then outputting the JSON within a script tag in the
 template, remembering to pipe it through safe. This little addition to
 Django would streamline that process.

 It lets you do this:
 {{{
 <script>
   var data = {{ data|json }};
 </script>
 }}}

 Instead of:
 {{{
 views.py:

 from django.utils import simplejson

 def home(request):
   data = {'hello: ['world', 'universe']}
   return render_to_response("home.html", {
     'data': simplejson.dumps(data),
     }, context_instance=get_context(request))


 home.html:

 <script>
   var data = {{ data|safe }};
 </script>

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17419>
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to