Skip to main content

a fast and full-featured template engine based on embedded Python

Project description


pyTenjin is a very fast and full-featured template engine. You can embed Python statements and expressions into your template file. pyTenjin converts it into Python script and evaluate it.


pyTenjin is enough stable, but it is under beta release. It means that API or specification may change in the future.


  • Very fast
    • About x10 faster than Django, x4 than Cheetah, x2 than Mako
    • In addition loading is very lightweight (important for CGI)
  • Full featured
    • Nestable layout template
    • Partial template
    • Fragment cache
    • Capturing
    • Preprocessing
  • Easy to learn
    • You don’t have to learn template-specific language
  • Supports Google App Engine

See User’s Guide and Changes for details.


$ sudo easy_install Tenjin


$ tar xzf Tenjin-X.X.X.tar.gz
$ cd Tenjin-X.X.X
$ sudo python install

Or just copy ‘lib/’ and ‘bin/pytenjin’ into proper directory.

(Optional) Install PyYAML.



<?py # -*- coding: utf-8 -*- ?>
<?py #@ARGS items ?>
<?py cycle = new_cycle('odd', 'even') ?>
<?py for item in items: ?>
  <tr class="#{cycle()}">
<?py #endfor ?>

import tenjin
#tenjin.set_template_encoding('utf-8')  # optional (defualt 'utf-8')
from tenjin.helpers import *
from tenjin.html import *
#import tenjin.gae; tenjin.gae.init()   # for Google App Engine
engine = tenjin.Engine()
context = { 'items': ['<AAA>', 'B&B', '"CCC"'] }
html = engine.render('example.pyhtml', context)


$ python
  <tr class="odd">
  <tr class="even">
  <tr class="odd">

See other examples .

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for Tenjin, version 1.1.1
Filename, size File type Python version Upload date Hashes
Filename, size Tenjin-1.1.1.tar.gz (206.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page