Skip to main content

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

Project description

About

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.

!!ATTENTION!!

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

Features

  • Very fast

    • About x10 faster than Django, x4 than Cheetah, x2 than Mako

    • In addition loading tenjin.py 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.

Install

$ sudo easy_install Tenjin

Or:

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

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

(Optional) Install PyYAML.

Example

example.pyhtml:

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

example.py:

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)
print(html)

Output:

$ python example.py
<table>
  <tr class="odd">
    <td>&lt;AAA&gt;</td>
  </tr>
  <tr class="even">
    <td>B&amp;B</td>
  </tr>
  <tr class="odd">
    <td>&quot;CCC&quot;</td>
  </tr>
</table>

See other examples .

Project details


Download files

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

Source Distribution

Tenjin-1.1.0.tar.gz (206.6 kB view details)

Uploaded Source

Built Distributions

Tenjin-1.1.0-py3.2.egg (55.0 kB view details)

Uploaded Source

Tenjin-1.1.0-py3.1.egg (55.0 kB view details)

Uploaded Source

Tenjin-1.1.0-py3.0.egg (28.0 kB view details)

Uploaded Source

Tenjin-1.1.0-py2.7.egg (54.5 kB view details)

Uploaded Source

Tenjin-1.1.0-py2.6.egg (54.5 kB view details)

Uploaded Source

Tenjin-1.1.0-py2.5.egg (54.5 kB view details)

Uploaded Source

File details

Details for the file Tenjin-1.1.0.tar.gz.

File metadata

  • Download URL: Tenjin-1.1.0.tar.gz
  • Upload date:
  • Size: 206.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Tenjin-1.1.0.tar.gz
Algorithm Hash digest
SHA256 8362db6942dc5b09f596cba36f325c1eb1f5c912b9beb9b3c724cc1c6c385865
MD5 f8b14f96c5ec6b87ea274be46e426469
BLAKE2b-256 42aa79c3cecf610f2e6f48a8ddfada1402d44de7a174c13b9c0678ad83690474

See more details on using hashes here.

File details

Details for the file Tenjin-1.1.0-py3.2.egg.

File metadata

  • Download URL: Tenjin-1.1.0-py3.2.egg
  • Upload date:
  • Size: 55.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Tenjin-1.1.0-py3.2.egg
Algorithm Hash digest
SHA256 a3c88caec4cb9dd4f1e57ad7056a3617e82c2157fd03dcf0a22faa3856fe7509
MD5 b32eefbe679729d9b131006f3598f454
BLAKE2b-256 6d9a5d98e3f1200f5348367f4795e2b55fb80b3169092c0f9b8a11bb8abf0f08

See more details on using hashes here.

File details

Details for the file Tenjin-1.1.0-py3.1.egg.

File metadata

  • Download URL: Tenjin-1.1.0-py3.1.egg
  • Upload date:
  • Size: 55.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Tenjin-1.1.0-py3.1.egg
Algorithm Hash digest
SHA256 c500f348f3bad7201784705d25684294eaaabc1072d62bccf04c5afbd616908c
MD5 44ac40385b80d4a8f0f4f3e762bea899
BLAKE2b-256 f79143ef10c5f4c5630d15f8493f41f8f557f9816cef484d8259595e21e251b3

See more details on using hashes here.

File details

Details for the file Tenjin-1.1.0-py3.0.egg.

File metadata

  • Download URL: Tenjin-1.1.0-py3.0.egg
  • Upload date:
  • Size: 28.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Tenjin-1.1.0-py3.0.egg
Algorithm Hash digest
SHA256 e944d793247eab1106e28efeffd70fed4d4ec5fa33b271c6e04b670428b36f0b
MD5 22fb13879f37686ddf0345e0652199d6
BLAKE2b-256 2f991b9e3c207dccb66cee7ea2638b216a97adc92a990c02ebaa220c93634490

See more details on using hashes here.

File details

Details for the file Tenjin-1.1.0-py2.7.egg.

File metadata

  • Download URL: Tenjin-1.1.0-py2.7.egg
  • Upload date:
  • Size: 54.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Tenjin-1.1.0-py2.7.egg
Algorithm Hash digest
SHA256 5ecbc5958708399ad54def961b2544443e95fe7a9b3b484f8c2c69a0e4c4ff26
MD5 5f04320282ce06e49eee82841e7417af
BLAKE2b-256 c1b007c4924acf8c35a1d308c494c543ca23bf1659528061517b77904c0dad46

See more details on using hashes here.

File details

Details for the file Tenjin-1.1.0-py2.6.egg.

File metadata

  • Download URL: Tenjin-1.1.0-py2.6.egg
  • Upload date:
  • Size: 54.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Tenjin-1.1.0-py2.6.egg
Algorithm Hash digest
SHA256 1211fa060c9a6633cb938018383dabdc71b66d9b87d9b167922aba5776841347
MD5 3a2875d115a381ca59343dd8cae5d61f
BLAKE2b-256 c62d3f051eb23771541a28edf322aa70c9ba6672e1b70ccc27ac7408879fa31c

See more details on using hashes here.

File details

Details for the file Tenjin-1.1.0-py2.5.egg.

File metadata

  • Download URL: Tenjin-1.1.0-py2.5.egg
  • Upload date:
  • Size: 54.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Tenjin-1.1.0-py2.5.egg
Algorithm Hash digest
SHA256 3122b80a4a41e84836024f60ac7f372135f13cd289f6be101ea81901017f675f
MD5 50e817332c3705e5631f985e5602163a
BLAKE2b-256 e98774f2713280d9f61aa87d0190260778063d597954563a09d9aef456166ebb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page