Standalone ZPT?

Richie Hindle richie at
Wed Aug 21 10:40:52 CEST 2002


> Are there any other Python templating systems that work like ZPT (i. e.
> use attributes instead of custom tags)?

You could look at PyMeld, my very lightweight HTML manipulation module:

>>> import PyMeld
>>> html = '''<html><body>
... <textarea id='message' rows='2' cols='50'>Enter a message here.</textarea>
... </body></html>'''
>>> page = PyMeld.Container( html )       # Create a Container from the HTML.
>>> page.message.content = "New message." # Change the content of a tag.
>>> page.message.rows = 10                # Change an attribute value.
>>> print page
<textarea id='message' rows='10' cols='50'>New message.</textarea>

PyMeld also lets you programatically create clones of pieces of HTML,
manipulate them programatically, and insert them back into your document;
there's an example on the web page of taking a table populated with one
row of dummy data and populating it with several rows of real data.

PyMeld has no special requirements for the HTML, other than that each
tag you want to manipulate must have an 'id' attribute, and the attribute
values must be quoted.  It works by string substitution rather than by
parsing and rebuilding the document, so it's immune to invalid or
incomplete HTML, as long as the pieces you want to manipulate make sense.

See for examples, documentation and
download.  (I have a new version that allows deletion of tags and
attributes, which I'll be publishing soon - let me know if you need

Richie Hindle

More information about the Python-list mailing list