Hi all,
please give me a change to introduce Tenjin template engine.
http://www.kuwata-lab.com/tenjin/

Tenjin is a very fast and powerful template engine.
It allows you to embed any Python code in template file.
Tenjin converts template file into Python script and evaluate it.
I believe that Tenjin will fit web.py because it is small and
lightweight.

Features:
* Tenjin is about
  - ten times faster than Templetor (= web.py's template engine)
  - three times faster than Cheetah
  - nine times faster than Django
  - sixty times faster than Kid
* Tenjin supports
  - layout template
  - partial template
  - capturing part of template
  - template encoding


Install:

$ wget http://downloads.sourceforge.net/tenjin/pytenjin-0.6.0.tar.gz
$ tar xzf pytenjin-0.6.0.tar.gz
$ cd pytenjin-0.6.0/
$ sudo python setup.py install


Example:

templates/layout.pyhtml:
--------------------
<html>
  <head>
    <title>${title}</title>
    <meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
  </head>
  <body>
    <h1>${title}</h1>
    <div id="maincontent">
#{_content}
    </div>
<?py include(':footer') ?>
  </body>
</html>
--------------------

templates/item_list.pyhtml:
--------------------
<table>
<?py i = 0 ?>
<?py for item in items: ?>
<?py     i += 1 ?>
<?py     color = i % 2 and '#FFCCCC' or '#CCCCFF' ?>
  <tr bgcolor="#{color}">
    <td>#{i}</td>
    <td>${item}</td>
  </tr>
<?py #endfor ?>
</table>
--------------------

templates/footer.pyhtml:
--------------------
<hr>
<address>
 <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
</address>
--------------------

main.py:
--------------------
import tenjin
from tenjin.helpers import escape, to_str
engine = tenjin.Engine(postfix='.pyhtml', path=['templates'],
                       layout=':layout', cache=True)
context = { 'title':'Example', 'items':['<AAA>','B&B','"CCC"'] }
#web.header('Content-Type', 'text/html; charset=UTF-8')
print engine.render(':item_list', context),
--------------------

output:
--------------------
<html>
  <head>
    <title>Example</title>
    <meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
  </head>
  <body>
    <h1>Example</h1>
    <div id="maincontent">
<table>
  <tr bgcolor="#FFCCCC">
    <td>1</td>
    <td>&lt;AAA&gt;</td>
  </tr>
  <tr bgcolor="#CCCCFF">
    <td>2</td>
    <td>B&amp;B</td>
  </tr>
  <tr bgcolor="#FFCCCC">
    <td>3</td>
    <td>&quot;CCC&quot;</td>
  </tr>
</table>

    </div>
<hr>
<address>
 <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
</address>
  </body>
</html>
--------------------

Tenjin has features which Templetor doesn't have yet.
If you want faster and more powerful template engine than Templetor,
try Tenjin.
http://www.kuwata-lab.com/tenjin/

--
makoto kuwata


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to