Related Entries

India PyCon 2009
Quick wallpaper changer
Load testing with Grinder
Adding namespace to XML
Opera RSS to OPML

« MySQL on Mandrake 9.1 with Python
» SWT for GUIs

Templating with Python

Finally, a templating utility I can use!

I had a small need for simple HTML/XML templating with Python. After a quick look around for different templating modules for Python available now, I zeroed in on the following four:

  1. Cheetah Template
  2. Tiny Template
  3. HTMLTMPL Template
  4. XYAPTU Template

I chose XYAPTU. Very simple and easy to understand code. It extends Alex Martelli’s YAPTU to be more XHTML/XML like.

Using XYAPTU is very simple. Make a template, with $variable for substitution variables. Then you define a dictionary called the name space and process the template with the name space. Examples are given within the module.

The realy beauty of this is that it supports conditionals, loops and expressions in addition to simple variable substitution. Just drop xyaptu.py and yaptu.py in your Python path and you are set to go!

  1. If template creators are Python programmers, best option available now is PyMeld: http://www.entrian.com/PyMeld/

    Posted by: Babu on May 20, 2003 06:46 PM
//-->