Template Lite: A Sweeter Smarty Alternative
I always love it when Padraic Brady’s blogs. I think it’s his writing style that makes it so enjoyable to read. (It could be that he always writes really long blogs so it’s easy for me to find pull-quotes for DevZone!) No matter what the reason, his is one of the blogs I monitor daily. (and I’m ever so glad he’s back on-line, I was going through withdrawals in July!)
His latest blog gives an excellent review of a template engine called Template Lite. Stepping carefully so as not to seem down on Smarty, Paddy contrasts Template Lite to the current gold standard in template engines, Smarty. More than just a feature comparison though, Paddy talks about when he feels Template Lite is an appropriate choice.
Enter Mark Dickenson. Mark is the developer of a Smarty alternative: Template Lite. Template Lite is not simply another template engine. It’s objective is to maintain Smarty compliance (i.e. it parses Smarty markup) using a redesigned library for minimal memory and CPU cycle consumption. Not happy with just that, Mark has also introduced some non-standard Smarty markup which, simply enough, provides more intuitive methods for traversing arrays, looping, etc. – for example, the SWITCH, FOR and WHILE tags. The results? A Smarty drop-in replacement which is limited to approx. 50% of Smarty’s usual memory usage and is significantly faster at compiling and displaying templates.
You’ll have to visit his blog for the whole article. Like most things Paddy posts, it’s worth the read.
=C=

Comments
What baffles me is everyone's insistence to mix logic into templates. To me, this goes against the whole point of separating content from logic.
If you're going to put logic into templates, then you almost may as well go back to just having HTML embedded in your PHP files.
And if you are like me, and dont use that functionality, why use a template class that was designed for it and pay the price of extra CPU cycles + memory usage for a feature you don't use?
Just my two cents. Templates are good. Logic in templates is, well, bad.
I wanted to qualify the statement about logic not belonging in the template.
You frequently hear people talking about the importance of separating logic from presentation. That's correct if by logic you mean business logic. However, there is often logic associated with the presentation and a template is a valid place to put that logic.
If you focus narrowly enough on the V part of the MVC pattern, you'll see the V itself is composed of its own MVC. Where else are you going to put that view logic?
I point this out because I encounter people from time to time who feel that ALL logic must be removed from the view because they think it's good design to "separate logic from presentation". They end up with presentation logic mixed with business logic. This is not good design.
Just my two cents.
-Rob