- Featured Columnists
Table of Contents
- Web Basics
- Publishing on the Web: Putting Files on the Server
- Web Design Process and Workflow
- Project Management
- Mark My WWWord: HTML and XHTML
- Standards Compliance
- Meta Tags and Search
- Enhancing Web Page Interaction
- Web Graphics
- Web Page Optimization
- Overview of Servers
- Server Programming Basics
- Careers in Web Design
- Intellectual Property for Web Designers
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 (http://www.w3.org/TR/xslt) and has a working draft of XSLT 2.0 (http://www.w3.org/TR/xslt20/). An alternative to XML/XSLT is Streaming Transformations for XML (STX), which provides high-speed and less memory consumption than XSLT.
Smarty (http://smarty.php.net/) and Savant2 (http://phpsavant.com/yawiki/) 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 (http://www.massassi.com/php/articles/template_engines/) on template engines discussing their background, purpose, and why most template engines don't have it right.