Пример #1
0
class TemplateLoader(BaseLoader):
    default_parser = language.Parser()

    formats = {
        "xml": template.GenshiTemplateFile,
        "text": template.GenshiTextTemplateFile,
    }

    def load(self, filename, format="xml"):
        """Load and return a template file. The format parameter determines
        will parse the file. Valid options are `xml` and `text`."""
        return super(TemplateLoader, self).load(filename, self.formats[format])
Пример #2
0
    <div class="header">
      <h1>${page_title}</h1>
    </div>
    <ul class="navigation">
    <li py:for="info in sections"><a href="${info[0]}">${info[1]}</a></li>
    </ul>
    <div class="table">
      <table>
        <tr py:for="row in table">
          <td py:for="cell in row">${row[cell]}</td>
        </tr>
      </table>
    </div>
  </body>
</html>\
""", parser=language.Parser())
    chameleon_genshi_context = dict(context)
    chameleon_genshi_context['sections'] = [
        ('index.html', 'Index'),
        ('downloads.html', 'Downloads'),
        ('products.html', 'Products')
    ]
    def test_chameleon_genshi():
        chameleon_genshi_template.render(**chameleon_genshi_context)


sys.stdout.write('\r' + '\n'.join((
    '=' * 80,
    'Template Engine BigTable Benchmark'.center(80),
    '=' * 80,
    "",