Most of web application architectures these days include one or another kind of a template engine. The template engine applies various templates on data contents and produces various presentation outputs. Using templates, it is easy to achieve style standardization (a common look-and-feel) on the web site, separate concerns of programming and presentation design etc.
We use XSLT 1.0 stylesheets as templates and PHP’s XSL extension as a template engine. XSLT is a language for transforming XML documents into other XML documents (not only, really). The engine on which the the transformations are run is usually called an XSLT processor.
For example, using 3 different templates, we produce XHTML, RSS, and Atom presentations from the same data contents.
There is a great variety of template engines, with Smarty being probably the most popular one for PHP. We argue however, that XSLT is the perfect template engine, and that is why we use it in our DIY Framework:
It is a standard
It is non-proprietary and platform-independent
It can be used in a wider context than web templating, i. e. in XML processing in general
It is a functional, Turing-complete language
It is included by default in many platforms
It readily includes many control structures, such as conditional statements/branches, sorting, and even file/HTTP access
There is a great variety of XSLT processors. These are usually separate highly-optimized C or Java libraries and therefore very fast.
Used correctly, it produces only well-formed XML (or XHTML, for that matter)
It is definitely worth learning XSLT instead of a proprietary template language that has yet another kind of syntax and a very narrow application.
Of course, it’s easiest to use XSLT when you have your data contents already present in an XML format (e. g. stored in XML files or a native XML database). But even if they are not, it is worth to serialize them into XML and then enjoy all the benefits of XSLT.