Baseplane Tool: Tenjin Templating Library (pyTenjin, jsTenjin, phpTenjin, rbTenjin, plTenjin)
Tenjin is a great templating library that gets not only cross platform but baseplane ability to make templating very similiar (and FAST) across many languages. pyTenjin and phpTenjin is currently what I am using but there are executions for Ruby, Perl and Javascript.
Here is a list of the Tenjin Templating engines:
- Changes
- (Python) (Ruby) (PHP) (Perl) (JavaScript)
- User’s Guide
- (Python) (Ruby) (PHP) (Perl) (JavaScript)
- FAQ
- (Python) (Ruby) (PHP) (Perl) (JavaScript)
- Examples
- (Python) (Ruby) (PHP) (Perl) (JavaScript)
- Presentation
- 2007 LL Spirit LightningTalk (full-version) (Japanese)
Here is what the template markup looks like:
This
<table>
<tbody>
<?py i = 0 ?>
<?py for item in ['<foo>', 'bar&bar', '"baz"']: ?>
<?py i += 1 ?>
<tr>
<td>#{item}</td>
<td>${item}</td>
</tr>
<?py #end ?>
<tbody>
</table>
Produces This
<table> <tbody> <tr> <td><foo></td> <td><foo></td> </tr> <tr> <td>bar&bar</td> <td>bar&bar</td> </tr> <tr> <td>"baz"</td> <td>"baz"</td> </tr> <tbody> </table>
Here are some speed results
| Language | Template Engine | Test#1(sec) | Test#2(sec) |
|---|---|---|---|
| Python(2.5.1) | pyTenjin (0.6.1) | 6.96 | 5.61 |
| Cheetah (2.0) | 20.36 | 19.82 | |
| Django (0.9.5) | 71.33 | 59.80 | |
| Myghty (1.1) | 107.88 | 19.30 | |
| Kid (0.9.6) | 380.24 | 378.96 | |
| Genshi (0.4.4) | 560.30 | 271.69 | |
| Mako (0.1.9) | 17.78 | 13.49 | |
| Templetor (web.py 0.22) | 428.19 | 61.53 | |
| Ruby(1.8.6) | rbTenjin (0.6.0) | 7.34 | 4.52 |
| eruby (1.0.5) | 12.29 | 11.53 | |
| ERB(def_method) (Ruby1.8.6) | 36.73 | 5.85 | |
| PHP(5.2.0) | phpTenjin (0.0.1) | 5.39 | 3.64 |
| Smarty (2.6.18) | 10.84 | 10.21 | |
| Perl(5.8.8) | plTenjin (0.0.1) | 10.42 | 5.72 |
| Template-Toolkit(XS) (2.18) | 103.58 | 26.30 | |
| HTML::Template (2.9) | 46.70 | 30.21 | |
| JS(spidermonkey) | jsTenjin (0.0.1) | 19.00 | 12.98 |
| JS(Rhino, JDK5) | jsTenjin (0.0.1) | 24.29 | 19.15 |
| Java(JDK5) | Velocity (1.4) | 22.80 | 11.41 |
| Velocity (1.5) | 20.01 | 8.42 |
Tags: javascript, js, jstenjin, perl, php, phptenjin, pltenjin, pytenjin, python, rbtenjin, ruby, template, tenjin

How to install jstenjin under Windows?
You can just take the jstenjin.js files from the download and reference them. No install needed.
I wanna try for PHP edition so how can i run?
I haven’t used the PHP one yet but may post a tutorial on it. PHP by nature is also a templating language but this makes a common way to use templating across all languages. It takes exterenal template files and then can merge them with your models. This provides a better MVC separation.
Basically though you just download the php files and then hit these examples: http://www.kuwata-lab.com/tenjin/phptenjin-examples.html