Mercurial > genshi > mirror
changeset 543:0449396999c5 trunk
Replace Myghty by Mako in bigtable benchmark, apply escaping in Mako templates.
author | cmlenz |
---|---|
date | Thu, 28 Jun 2007 18:12:15 +0000 |
parents | 1912af29ac70 |
children | 82e37439c5f4 |
files | examples/bench/bigtable.py examples/bench/mako/header.html examples/bench/mako/template.html |
diffstat | 3 files changed, 18 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/examples/bench/bigtable.py +++ b/examples/bench/bigtable.py @@ -41,9 +41,9 @@ DjangoContext = DjangoTemplate = None try: - from myghty.interp import Interpreter as MyghtyInterpreter + from mako.template import Template as MakoTemplate except ImportError: - MyghtyInterpreter = None + MakoTemplate = None table = [dict(a=1,b=2,c=3,d=4,e=5,f=6,g=7,h=8,i=9,j=10) for x in range(1000)] @@ -74,23 +74,21 @@ context = DjangoContext({'table': table}) django_tmpl.render(context) -if MyghtyInterpreter: - interpreter = MyghtyInterpreter() - component = interpreter.make_component(""" +if MakoTemplate: + mako_tmpl = MakoTemplate(""" <table> -% for row in ARGS['table']: - <tr> -% for col in row.values(): - <td><% col %></td> -% -% - </tr> + % for row in table: + <tr> + % for col in row.values(): + <td>${ col | h }</td> + % endfor + </tr> + % endfor </table> """) - def test_myghty(): - """Myghty Template""" - buf = StringIO() - interpreter.execute(component, request_args={'table':table}, out_buffer=buf) + def test_mako(): + """Mako Template""" + mako_tmpl.render(table=table) def test_genshi(): """Genshi template""" @@ -186,7 +184,7 @@ def run(which=None, number=10): tests = ['test_builder', 'test_genshi', 'test_genshi_builder', - 'test_myghty', 'test_kid', 'test_kid_et', 'test_et', 'test_cet', + 'test_mako', 'test_kid', 'test_kid_et', 'test_et', 'test_cet', 'test_clearsilver', 'test_django'] if which:
--- a/examples/bench/mako/header.html +++ b/examples/bench/mako/header.html @@ -1,5 +1,5 @@ <div id="header"> - <h1>${title}</h1> + <h1>${title | h}</h1> </div>
--- a/examples/bench/mako/template.html +++ b/examples/bench/mako/template.html @@ -7,7 +7,7 @@ </head> <body> <%def name="greeting(name)"> - <p>Hello, ${name}!</p> + <p>Hello, ${name | h}!</p> </%def> <%include file="header.html"/> @@ -20,7 +20,7 @@ % if items: <ul> % for idx, item in enumerate(items): - <li ${idx+1==len(items) and "class='last'" or ""}>${item}</li> + <li ${idx+1==len(items) and "class='last'" or ""}>${item | h}</li> % endfor </ul> % endif