Templating Systems Compared and Contrasted
By Chris Withers from Simplistix Ltd
Independent Zope and Python consultant. Using Zope and Python since 1999.
Python 2.4 gives string templating, which is better than e.g. print statements.
Quixote - PTL:
- allows template re-use
- broken html possible
- what would an html-only person think?
Zope - DTML:
- It is a generic scripting language
- Highly tied to acquisition
- Tell the html writers to leave the dtml variable alone and they can do the rest.
- simple templates
- not just xml/html
- one big namespace
- not good with dreamweaver and friends
Zope - ZPT
Well known in the Zope community.
Positives: - Clean namespaces
- limits you from introducing business logic in templates
- source is valid xml/html
- 2 or 3 new languages
- macros are confusing, especially nesting them
- very tied to Zope
- tied to generating xml/html
- not limited to xml
- not tied to one framework
- familiar, python-like
- not enough python-like, so yet another language
- we're not helping the web monkeys
Nevow: really aimed at twisted.nevow
- Clean separation of data, logic and presentation
- does help the web monkeys
- very verbose
- meant for Twisted and yes it is twisted!
Others: - Myghty
- PyMeld, meld2, meld3
- Kid attribute language like ZPT
Types: preprocessor, class based, attribute languages, DOM based
We want to:
- Replace attributes, values and tags.
- Repeat tags
- Remove attributes, values, tags and node
- html quoting
What if we did that?
- no new languages
- work with raw html
- n = t.getById(
- n.replace(value, tag, **attributes)
- n.repeat(value, tag, **attributes)
- Put code in html comments, mostly at the top.
- t.clone() for reusing common material
- Use name attributes:
- works with real html
- no new language
- simple as possible
- not battle-proven
- maybe slow
I hadn't seen meld3 when i started developing Twiddler, but they are scarily similar. It uses meld:id attribute.
But it's not just about html. Think about sending an email. Or a css file. Or things that are just not xml.
What about i18n, html quoting, stx, rst? We can do that.
See the presentation.