Personal tools
You are here: Home Weblog Archive 2006 month_jul Templating Systems Compared and Contrasted
Document Actions

Templating Systems Compared and Contrasted

Filed Under:

Technorati tags:

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:

import quixote quixote.enable_ptl()

Positives:

  • allows template re-use

Negatives:

  • 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.

Positives:

  • simple templates
  • not just xml/html

Negatives:

  • acquisition
  • 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

Negatives:

  • 2 or 3 new languages
  • macros are confusing, especially nesting them
  • very tied to Zope
  • tied to generating xml/html

Cheetah

  • not limited to xml
  • not tied to one framework

Positives:

  • familiar, python-like
  • compact
  • caching

Negatives:

  • not enough python-like, so yet another language
  • we're not helping the web monkeys

Nevow: really aimed at twisted.nevow

Positives:

  • Clean separation of data, logic and presentation
  • does help the web monkeys

Negatives:

  • very verbose
  • meant for Twisted and yes it is twisted!

Others: - Myghty

  • Preppy
  • XSLT
  • 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?

  • simple
  • no new languages
  • work with raw html

Twiddler

  • n = t.getById(Something)
  • n.replace(value, tag, **attributes)
  • n.repeat(value, tag, **attributes)
  • n.remove()
  • Put code in html comments, mostly at the top.
  • t.clone() for reusing common material
  • Use name attributes: </li> </ul> <p>Positives:</p> <ul> <li>works with real html</li> <li>no new language</li> <li>simple as possible</li> </ul> <p>Negatives:</p> <ul> <li>verbose</li> <li>not battle-proven</li> <li>maybe slow</li> </ul> <p>I hadn't seen meld3 when i started developing Twiddler, but they are scarily similar. It uses meld:id attribute.</p> <p>But it's not just about html. Think about sending an email. Or a css file. Or things that are just not xml.</p> <p>What about i18n, html quoting, stx, rst? We can do that.</p> <p>See the <a href="http://www.simplistix.co.uk/presentations">presentation</a>.</p> </div> </div> <div id="relatedItems"> </div> <div class="weblog-about"> <div class="entry-trackback"> </div> </div> </div> </div> </div> </td> <td id="portal-column-two"> <div class="visualPadding"> <dl class="portlet" id="portlet-quills"> <dt class="portletHeader">Syndication <span class="portletTopLeft"></span> <span class="portletTopRight"></span> </dt> <!-- Only show atom feed for current language. --> <dd class="portletItem odd" id="quills-portlet-atom"> <a href="http://new.maurits.vanrees.org/weblog/atom.xml"> <img src="http://new.maurits.vanrees.org/atom_feed.gif" height="15" width="80" alt="Atom" title="Atom Enabled" /> </a> </dd> <dd class="portletItem odd" id="quills-portlet-atom-plone"> <a href="http://new.maurits.vanrees.org/weblog/topics/plone/@@atom.xml"> <img src="http://new.maurits.vanrees.org/plone_only.png" height="15" width="80" alt="Plone feed" title="Plone only atom feed" /> </a> </dd> <dd class="portletFooter" id="quills-portlet-quills"> <a href="http://plone.org/products/quills"> <img src="http://new.maurits.vanrees.org/quills_powered.gif" height="15" width="80" alt="Powered by Quills" title="Quills weblog system for Plone: by Etria" /> </a> <span class="portletBottomLeft"></span> <span class="portletBottomRight"></span> </dd> </dl>   </div> </td> </tr> </tbody> </table> <div class="visualClear"><!-- --></div> <hr class="netscape4" /> <div id="portal-footer"> <p> The <a href="http://plone.org">Plone<sup>®</sup> CMS — Open Source Content Management System</a> is Copyright © 2000-<span>2008</span> by the <a href="http://plone.org/foundation">Plone Foundation</a> et al. </p> <p> <span> Plone<sup>®</sup> and the Plone logo are registered trademarks of the <a href="http://plone.org/foundation">Plone Foundation</a>. </span> <span> Distributed under the <a href="http://creativecommons.org/licenses/GPL/2.0/">GNU GPL license</a>. </span> </p> </div> <div id="portal-colophon"> <a href="http://plone.org" class="colophonIcon colophonIconPlone" title="This Plone site was built using Plone CMS, the Open Source Content Management System. Click for more information."> Powered by Plone CMS, the Open Source Content Management System </a> <p class="discreet"> This site conforms to the following standards: </p> <div class="colophonWrapper"> <ul> <li> <a href="http://www.section508.gov" class="colophonIcon colophonIcon508" title="This Plone site conforms to the US Government Section 508 Accessibility Guidelines."> Section 508 </a> </li> <li> <a href="http://www.w3.org/WAI/WCAG1AA-Conformance" class="colophonIcon colophonIconWAI" title="This Plone site conforms to the W3C-WAI Web Content Accessibility Guidelines."> WCAG </a> </li> <li> <a href="http://validator.w3.org/check/referer" class="colophonIcon colophonIconXHTML" title="This Plone site is valid XHTML."> Valid XHTML </a> </li> <li> <a href="http://jigsaw.w3.org/css-validator/check/referer&warning=no&profile=css3&usermedium=all" class="colophonIcon colophonIconCSS" title="This Plone site was built with valid CSS."> Valid CSS </a> </li> <li> <a href="http://plone.org/browsersupport" class="colophonIcon colophonIconAnyBrowser" title="This Plone site is usable in any web browser."> Usable in any browser </a> </li> </ul> </div> </div> </div> </body> </html>