Ian Bicking: the old part of his blog

Neutral Templating

I've been thinking about templating for a while now. Here my thoughts, and here's what they make.

It's only two evenings work so far, so don't expect too much. Like lots of examples or docs or any consideration of real use cases.

I used lxml for this; the killer feature is HTML parsing:

from lxml import etree
parsed_html = etree.HTML(html_string)

That's darn easy, and none of that Tidy crap (it was still cool in 1999, but I've way over Tidy by 2006).

Update: in an email Kevin Dangoor pointed me to SiteMesh, another tool in the same veign for Java. He also noted Kids' py:match support makes it possible to apply templates to content (py:match is vaguely similar to what XSLT does). Kid could really use that lxml HTML parsing too.

One design feature of WSGIOverlay is that the system is not connected to Python, or even to WSGI (despite the name); though clearly the implementation is connected to both those things. This is distinct from Kid and SiteMesh, where templates are associated with specific languages (Python/Kid and Java/JSP). Unlike Kid and JSP, WSGIOverlay is entirely useless for creating content, it is only useful for composing content.

Created 08 Jun '06
Modified 08 Jun '06


You might find this interesting http://www.kuwata-lab.com/kwartz/ from the Ruby crowd.

# ksmith99

I think that's pretty different in motivation, if I understand what they are doing. It reminds me of XMLC and similar products, but with a more CSS-ish feel. It's also about separating Business Logic from Presentation Logic, and WSGIOverlay doesn't do that in the slightest. It's really more about separating site composition from the templating of individual applications.

# Ian Bicking