Edgewall Software

Changeset 652


Ignore:
Timestamp:
Jun 28, 2007, 8:12:15 PM (16 years ago)
Author:
cmlenz
Message:

Replace Myghty by Mako in bigtable benchmark, apply escaping in Mako templates.

Location:
trunk/examples/bench
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/bench/bigtable.py

    r587 r652  
    4242
    4343try:
    44     from myghty.interp import Interpreter as MyghtyInterpreter
    45 except ImportError:
    46     MyghtyInterpreter = None
     44    from mako.template import Template as MakoTemplate
     45except ImportError:
     46    MakoTemplate = None
    4747
    4848table = [dict(a=1,b=2,c=3,d=4,e=5,f=6,g=7,h=8,i=9,j=10)
     
    7575        django_tmpl.render(context)
    7676
    77 if MyghtyInterpreter:
    78     interpreter = MyghtyInterpreter()
    79     component = interpreter.make_component("""
     77if MakoTemplate:
     78    mako_tmpl = MakoTemplate("""
    8079<table>
    81 % for row in ARGS['table']:
    82    <tr>
    83 %    for col in row.values():
    84      <td><% col %></td>
    85 %
    86 %
    87    </tr>
     80  % for row in table:
     81    <tr>
     82      % for col in row.values():
     83        <td>${ col | h  }</td>
     84      % endfor
     85    </tr>
     86  % endfor
    8887</table>
    8988""")
    90     def test_myghty():
    91         """Myghty Template"""
    92         buf = StringIO()
    93         interpreter.execute(component, request_args={'table':table}, out_buffer=buf)
     89    def test_mako():
     90        """Mako Template"""
     91        mako_tmpl.render(table=table)
    9492
    9593def test_genshi():
     
    187185def run(which=None, number=10):
    188186    tests = ['test_builder', 'test_genshi', 'test_genshi_builder',
    189              'test_myghty', 'test_kid', 'test_kid_et', 'test_et', 'test_cet',
     187             'test_mako', 'test_kid', 'test_kid_et', 'test_et', 'test_cet',
    190188             'test_clearsilver', 'test_django']
    191189
  • trunk/examples/bench/mako/header.html

    r648 r652  
    11<div id="header">
    2   <h1>${title}</h1>
     2  <h1>${title | h}</h1>
    33</div>
    44
  • trunk/examples/bench/mako/template.html

    r648 r652  
    88  <body>
    99    <%def name="greeting(name)">
    10       <p>Hello, ${name}!</p>
     10      <p>Hello, ${name | h}!</p>
    1111    </%def>
    1212 
     
    2121      <ul>
    2222        % for idx, item in enumerate(items):
    23           <li ${idx+1==len(items) and "class='last'" or ""}>${item}</li>
     23          <li ${idx+1==len(items) and "class='last'" or ""}>${item | h}</li>
    2424        % endfor
    2525      </ul>
Note: See TracChangeset for help on using the changeset viewer.