The PEAR ITX Templating System - Searching for solutions
(Page 2 of 5 )
I started searching for more mature templating systems. I didn't have an exact set of goals in mind, but I did know what I wanted to achieve: 1. Code clarity 2. Ease of template writing for my clients
Here are the systems that I tried out while looking for The One Templating System :)
XSL TransformationsFor those of you that don't know it yet, XSL is an XML application that focuses on formatting the contents of an XML document to anything you can think of. You could for instance, generate SQL queries or HTML.
Unfortunately, XSLT wasn't what I was looking. My source code wasn't mixed into the HTML any more, but the code looked like hell. I wasn't generating HTML with echo() calls any more... I just switched over to generating XML with sprintf() calls and then using built in PHP functions to merge the XML and XSLT document into HTML.
The second problem is only apparent when you see an example of an XSLT file. XSLT is an XML application. Therefore, every XSLT must comply to a strict set of rules. Even the smallest mistake will cause strange errors, unexplained problems and general buggery. XSLT also has dreams to be more than (in my oppinion) it needs to be, so the syntax is not something your average Joe L. User could easily understand.
SmartyNow, Smarty is nice. It has a ton of features, most of which likely nobody ever uses. Of the better ones, I definitely need to mention template caching and an advanced support for built in template functions.
I liked Smarty, but it still wasn't what I was looking for. It had too much stuff in it, when I only needed the simplemost templating that would get me through the project, so I kept looking.
If you have a really large volume website, you could possibly benefit from Smarty's templating. On the other hand, I don't think you will. Smarty only supports age-based caching, and it uses plain files to cache documents.
And finally... IT/ITXIntegrated Template system and it's bigger brother Integrated Template eXtension are two of the scripts from the PEAR package.
I was surprised by the apparent lack of good documentation pertaining to this templating system. Until I realized how to get this thing working, I've read the source for ITX several times. Most of the documentation was imbedded directly into the source and examples are... well... non-existant.
Fortunately for me, something kept pushing me on to investigate, and in the end it turned out that ITX is exactly the thing I was looking for. It had support for blocks and variables, some primitive support for calling PHP functions directly from the template (if you ever find yourself in need of that) and a very easy template syntax for my users. I found this last feature more important than anything else that other templating systems could offer!
Compared to Smarty, ITX is definitely smaller and lighter. Many things are missing, and yet I'd say that the thing most of the folks will find missing is caching. If you need caching you can still implement it with finer cache expiery methods than those of Smarty. I suppose there will also be a tutorial about ITX caching and cache control at some point in time.
So, after this long introduction let's get down to business!
Next: Adding ITX to your PHP script >>
More PEAR Articles Articles
More By Codewalkers