Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > Usability

Web Design Reference Guide

Hosted by

Template Engines

Last updated Oct 17, 2003.

You hear about the separation of content from style when it comes to CSS and XHTML. Template engines or XML/XSLT offer another type of separation. These separate business logic from presentation logic rather than separating markup from server programming as some believe. Logemann describes template engines as a way to do MVC (model, view, controller) style application.

Using a template engine makes it easier to make changes and avoid duplication. Proponents, however, say most template engines are generic and too complex, especially for anyone managing a couple of sites. When it comes to running large or multiple Web sites, template engines can save time, but it's recommended that you create your own rather than use existing ones. Many of the articles covering the topic refer to PHP (also a template engine!), but template engines work with other languages as well.

Much like CSS provides the presentation while XHTML handles content, XSLT does the conversion for XML. W3C current recommendation is XSLT 1.0 ( and has a working draft of XSLT 2.0 ( An alternative to XML/XSLT is Streaming Transformations for XML (STX), which provides high-speed and less memory consumption than XSLT.

Smarty ( and Savant2 ( are template engines for PHP. PERL has HTML::Template. Velocity, an open source template engine, works as a standalone application or a servlet. ClearSilver works with Python. Smarty and XML/XSLT are the most used.

Brian Lozier, who has used and created template engines, writes an excellent article ( on template engines discussing their background, purpose, and why most template engines don't have it right.