From d94ea6b295647b876b1fbd1236ae6ee0b896ab7f Mon Sep 17 00:00:00 2001 From: mdipierro Date: Mon, 14 Mar 2016 15:08:18 -0500 Subject: [PATCH] simplified beautify example --- applications/examples/controllers/template_examples.py | 2 +- applications/examples/views/default/examples.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/examples/controllers/template_examples.py b/applications/examples/controllers/template_examples.py index addb8d07..94b7c6e0 100644 --- a/applications/examples/controllers/template_examples.py +++ b/applications/examples/controllers/template_examples.py @@ -27,4 +27,4 @@ def xml(): def beautify(): - return dict(message=BEAUTIFY(request)) + return dict(message=BEAUTIFY(dict(a=1,b=[2,3,dict(hello='world')]))) diff --git a/applications/examples/views/default/examples.html b/applications/examples/views/default/examples.html index b6b33de3..9debd288 100644 --- a/applications/examples/views/default/examples.html +++ b/applications/examples/views/default/examples.html @@ -278,7 +278,7 @@ def xml():

Example {{=c}}{{c+=1}}

In controller: template_examples.py {{=CODE(""" def beautify(): - return dict(message=BEAUTIFY(request)) + dict(message=BEAUTIFY(dict(a=1,b=[2,3,dict(hello='world')]))) """.strip(),language='web2py',link=URL('global','vars'),_class='boxCode')}}and view: template_examples/beautify.html {{=CODE(open(os.path.join(request.folder,'views/template_examples/beautify.html'),'r').read(),language='html',link=URL('global','vars'),_class='boxCode')}}

You can use BEAUTIFY to turn lists and dictionaries into organized HTML.