Cubictemp - Introduction

A small, elegant templating system for Python.

Features

  • Simple, well-tested and well-documented.

  • Integrates tightly with Python - pass arbitrary Python objects into a template, walk sequences and iterators, evaluate expressions.

  • Default escaping helps to prevent common classes of Cross-Site Scripting vulnerabilities.

  • Encourages separation of interface and program logic by disallowing statements in templates.

  • Tiny - only ~ 170 SLOC. There are many large, over-designed Python templating systems out there. Cubictemp proves that a templating sytem can be complete, elegant, powerful, fast and remain compact.

Cubictemp requires Python 2.4 or newer.

Hello walrus

import cubictemp

template = cubictemp.Template("Hello @!foo!@!", foo="walrus")
print template
print template(foo="world")

Output:

Hello walrus!
Hello world!

Copyright Nullcube 2008