[thelist] PHP Templating recommendations

Maximillian Schwanekamp lists at neptunewebworks.com
Wed Feb 2 16:48:11 CST 2005


Matt Warden wrote:
> Point taken. But, as I said in my last email, there are a lot of cases
> out there where Smarty would be appropriate and beneficial, but
> developers excuse ignoring it by saying that it is 'like a
> sledgehammer for a thumbtack' or other such phrases, when what they
> really mean is that they are afraid to learn a new syntax (which is
> ridiculously trivial). I am not saying it applies here.

In a bit of self-defense as the OP here, I'd like to say that I think 
Smarty is excellent, and I've been using it increasingly regularly for 
the past 6 months or so.  It's really not hard to get started in Smarty, 
and the overall benefits are huge, especially once you really start 
getting into it.  Rather like PHP itself... :)

>>Smarty is a non-trivial amount of code (~4000 lines) and requires some
>>server infrastructure as well. <snip />
> I didn't have to change any server configuration. It's just a couple
> included files. Your codebase argument is valid, though.

The "sledgehammer" analogy came up for me when I noticed that 
non-cacheable {section}{/section} blocks (e.g. search results pages) 
were being compiled and sent to the browser a bit too slowly.

What I've gone with is to go ahead with Smarty, but instead of using 
{section} blocks in Smarty, I'm instead doing a small set of utility 
classes to generate the HTML within php, and put the block of HTML 
content in the Smarty template with a simple {$var}.  With Smarty's 
caching features for the mostly-static elements, this seems to me a good 
compromise.

-- 
Maximillian Von Schwanekamp
http://www.neptunewebworks.com/



More information about the thelist mailing list