Skip to main content

A fast and full-featured template engine based on embedded Python (maintained fork)

Project description

PyPI version Python versions License: MIT

PyTenjin

This is a maintained fork of the original Tenjin template engine, which is no longer actively maintained.

Original project: https://pypi.org/project/Tenjin/

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 evaluates it.

Features

  • Very fast: Approximately 10x faster than Django, 4x faster than Cheetah, 2x faster than Mako
  • Full featured:
    • Nestable layout templates
    • Partial templates
    • Fragment caching
    • Capturing
    • Preprocessing
  • Easy to learn: Simple and intuitive syntax

Installation

pip install pytenjin

Quick Example

Template file (table.pyhtml):

<?py #@ARGS items ?>
<table>
  <?py for item in items: ?>
  <tr>
    <td>{=item=}</td>
  </tr>
  <?py #end ?>
</table>

Python code:

import tenjin
from tenjin.helpers import *

engine = tenjin.Engine()
context = {'items': ['AAA', 'BBB', 'CCC']}
html = engine.render('table.pyhtml', context)
print(html)

Output:

<table>
  <tr>
    <td>AAA</td>
  </tr>
  <tr>
    <td>BBB</td>
  </tr>
  <tr>
    <td>CCC</td>
  </tr>
</table>

Template Syntax

PyTenjin supports multiple expression syntaxes:

  • {=...=} - escaped expression (recommended)
  • {==...==} - raw expression (recommended)
  • ${...} - escaped expression (deprecated)
  • #{...} - raw expression (deprecated)

Note: The ${...} and #{...} syntax is deprecated and will be removed in a future version. Please use {=...=} and {==...==} instead.

License

MIT License

Original copyright by kuwata-lab.com

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

pytenjin-1.0.0.tar.gz (93.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytenjin-1.0.0-py3-none-any.whl (27.8 kB view details)

Uploaded Python 3

File details

Details for the file pytenjin-1.0.0.tar.gz.

File metadata

  • Download URL: pytenjin-1.0.0.tar.gz
  • Upload date:
  • Size: 93.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pytenjin-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1a6351115269f99b4a777c3a38f9d240e3c5962df61f9911987c8df3acc97187
MD5 17db262858f89861a3965251f2e1cc51
BLAKE2b-256 8b0c456520ddff07e0604f3902ff90a89279e7d22a22be4587a4456f8401f309

See more details on using hashes here.

File details

Details for the file pytenjin-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pytenjin-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 27.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pytenjin-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af0960c313ef3e3f4b6225ff5cf9647327f8748b6be62e4bdaaee61a41052361
MD5 ff4dda60d7c81ae17ad24f2cd53fc910
BLAKE2b-256 9133ec3473809cd5cb68386dcf611c76d1f7a53080a8b8d3e16607ed33ce8427

See more details on using hashes here.

Supported by

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