NYCPHP Meetup

NYPHP.org

[nycphp-talk] Templating engines

Gary Mort bz-gmort at beezifies.com
Fri Jan 18 19:25:24 EST 2008


Yitzchak Schaffer wrote:
> Greetings all --
>
> The current thread on beginner to intermediate has brought up Smarty; 
> I have been wondering about the relative advantanges of PHP templating 
> engines.  

A templating engine has two purposes.

1) It enforces, to a degree, the seperation of business/programming 
logic from display logic.

2) It provides a simplified mechanism for changing the presentation 
logic, without requiring changes to complex code.


The first goal can be met by simply adopting a MVC methodology, or any 
other system and creating your templates in PHP.  This has the added 
benefit of not needing to learn a new language, so of course PHP 
programmers prefer this(why add work for themselves?)

The latter depends on the sophistication of your users.  Some of them 
can handle updating PHP templates.  Some of them just want a simple 
system where they have a few keywords they can replace with other 
data(witness the massive popularity of programs such as Constant 
Contact).  Others are in the middle. 

For them, systems like Smarty can provide a big benefit.  They also gain 
the added benefit that if they make a mistake, no PHP programs will break.

In the end, you have to decide based on your user base.

For myself, I choose to support Smarty as it seems the most popular.  
And in my book, when your making systems for other people, only halfway 
technicaly sophisticated, it's best to provide them with a system that 
has a broad base they can go to for help.



More information about the talk mailing list