With an article on the
Smarty templating system over at
PHPBuilder.com and an article on the
Template IT PEAR package on the
Sitepoint blog today seems to be the day to discuss templating systems.
Not being one to miss a band wagon I thought I would jump on as well.
Although the PHPBuilder article is far more in depth I believe that Ian Muir gives the best explanation for why a templating system is a good thing to have and use.
In many projects, I felt I was doing a great job until I had to do a markup change and jump through a lot hurdles to make it happen.
Although there are other ways of dealing with this issue templating systems are a popular option. Some of the most popular templating systems also integrate little extras like caching and plugins which make it faster and easier to create forms, menus and even image thumbnails.
Although these extras are nice the key point of a templating system is to separate the 'business' logic from the presentation. This has proved useful in my latest project. Having found a template for this blog which I'm generally happy with I want to carry the same design through to the rest of the planned site. If the logic and presentation had been intermixed in the serendipity code two things would have happened. Firstly the idea of choosing from a variety of templates at all just wouldn't have been possible. Secondly, copying a design to other pages would have essentially meant starting the design again.
As it is I can simply take the template files, load different data into the variables and the page is good to go.
So far all this has been done in the Smarty templating system which is an extremely powerful system. For my needs too powerful so instead I decided to move to
TemplateLite. Supposedly this was going to be easy. TemplateLite was designed to be a direct replacement for all the Smarty functionality I was going to be using. To my great relief it worked perfectly.
I'm quite a fan of TemplateLite but templating systems seem to be a lot like frameworks - everyone wants to build their own. So with that in mind here is a list of the templating systems I know about.
- PEAR Templating Systems
- Smarty
- TemplateLite
- Savant
- Know any others? Let me know in the comments