Some thoughts considering templating languages

There are already a lot of templating languages out there. We see however that many frameworks also felt the need to write a templating system of their own. Another observation is that for now none of the current templating languages is considered outstanding.

Two discussions emerge often when researching templating.

  1. How to leverage html with a templating syntax
    • tag libraries: from an xml point of view, this is the most convenient style - html templates are however invalidated
    • attribute driven: has the advantage that a html template remains valid and can be viewed/edited in an ordinary wysiwyg editor
    • text tags (curly braces): html can remain valid but the templating logic disturbs the page layout
  2. Amount of logic to put in the templating language
    • how much of the logic should be handled in the templates ?
    • logic is sometimes needed, but it shouldn't be too powerful/convenient to do stuff that really should be done at the backend
    • who should be able to understand the logic or even manipulate it ?
      • e.g. JSP -> only java developers
      • e.g. jxtemplate -> everyone who can think logically

Initial research/inspiration

Django

  • (python based) framework with it's own (text based) templating language
  • one of the more popular, has some big sites running it
  • {% ... %} and {{ ... }} text tags
  • restricted syntax to express presentation, not express (advanced) logic (own extensions can be added)
  • nice features: template inheritance, (chained !) filters, looping over list of lists (for x,y in points), ifchanged in loop, include/ssi,  url features

Kid

  • Kid is a simple template language for XML based vocabularies written in Python
  • popular attribute language
  • parses XML as XML (sax alike ?)

Velocity

  • java engine
  • easy access to java context
  • especially aimed at java developers

Tapestry

  • uses attributes + has some features for keeping the html-templates viewable in wysiwyg editors
  • parser is flexible: they consider it a feature that source and resulting html are not necessarily valid (dangling tags)
  • built in i18n features
  • template system consists of template + specification + (binding) java class

Wicket

  • (apache) component oriented framework
  • in wicket the focus is on java code not on the template. Wicket templates are simple and limited (purposefully) whereas tapestry allows for a lot more customization from within the template. Wicket's approach makes sure all your logic is kept in code.

Zope ZPT / TAL

  • python based 
  • attribute driven -> html viewable/editable in wysiwyg
  • statements for replacing entire tags, their contents or some attributes / repeat and omit tags / join parts of several templates/ simple error handling

JSP

  • explicit java code
  • expression language: EL evolved to UEL which has an implementation JUEL !

Facelets

Other

  • JXTemplate : SAX !
  • Hamlets: servlet extensions, uses sax, id's + java binding

Needs and expectations

see report of our first meeting on this subject