NYCPHP Meetup

NYPHP.org

[nycphp-talk] To Smarty Or Not to Smarty: That Is The Question

Richard Harding rharding at mitechie.com
Tue Sep 5 06:43:40 EDT 2006


Mikko Rantalainen wrote:
> Richard Harding wrote:
>> LeeEyerman at aol.com wrote:
>>>  
>>> Can anyone give any guidance about when to and when not to use Smarty?  
>>  > ...snip
>>> Any information that could assist my reasoning, one way or the other, 
>>> would be greatly appreciated!
>> If your template designers are not php developers then using smarty as 
>> an interface that the designers can use might make some sense. If the 
>> guys doing the php are also doing the designing then I would suggest you 
>> take a peek at something like Savant or other php based solution.
> 
> I'm a bit OOP guy and I still think that I don't need Smarty or any 
> other template system for developing applications with (X)HTML front 
> end. I haven't yet seen a template system that has the power to turn 
> the application to some non-HTTP/HTML based frontend easily. And if 
> such template system needs JavaScript for the "HTML" front end, I'm 
> not interested.
> 
> The reason I think that one shouldn't need a template system is that 
> (X)HTML is supposed to be only about the structure and semantics. If 
> you don't whip up a <table> element for layout the UI guys don't 
> need to modify the (X)HTML source. They just touch the CSS file.

I have to say that there are other advantages of using a template 
system. I mean do you really want to hand type every <select 
name=""><option>...?

I also make sure any data passed into the template system is escaped on 
output. This helps prevent some nasty little surprises from time to time.

Personally, I like the template system approach. I have builders that 
perform my logic. They use my objects to fetch the list of user accounts 
from the database, for instance. Then I assign that list to the template 
system. The data is now available for output. I can then create numerous 
templates that use that same data for various types of output. One 
builder might power 5 different template views and I only have to update 
that one builder if some logic changes and all 5 templates are up to 
date. I don't so how you go about that type of flexibility without a 
template system of some sort. Care to share some info on how you use 
straight style sheets to get your output going?

Rick




More information about the talk mailing list