NYCPHP Meetup

NYPHP.org

[nycphp-talk] Smarty Templates

Marc Antony Vose suzerain at suzerain.com
Wed Nov 2 18:09:33 EST 2005


Just thought I'd chime in.

I think the advantage of Smarty (and like tools) is not so much 
separation of logic and display, because, as many have pointed out, 
it's got conditionals and looping, which to me is "logic".

I think the advantage of a system like that, on a large team, is 
really just control or security.  In other words, if your templating 
engine can only do certain things, this means that the templates can 
also not possibly screw something else up.

That said, I tend not to use any kind of templating.  For me, writing 
{%variable%} is not any easier than writing <?php echo $variable; ?>, 
and I'd prefer to just have my layout people learn a smattering of 
PHP (rather than some arbitrary template syntax), so that they 
themselves can learn to understand these issues, and can expand their 
skill set.

So I enforce the logic/display paradigm through discipline.  Our 
publishing engine just has this separation built in, and our 
'display' files only contain variable echoing, and simple logic or 
looping.  The rule is, basically, no "calculations" or "data 
retrieval" happens in the display files (duh).

But, if issues of control or security were extremely important to me, 
or if my team was too large to monitor, then I might reconsider 
routing everything through a templating engine and accept the 
performance hit.

-- 
Marc Antony Vose
http://www.suzerain.com/

"Anyone who is capable of getting themselves made President should on 
no account be allowed to do the job."
  - Douglas Adams



More information about the talk mailing list