D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] php templates

 

On 11/05/07, Simon Waters <simon@xxxxxxxxxxxxxx> wrote:
> Steve Marvell wrote:
> > I'm really quite used to using Template Toolkit with Perl, but have
> > been asked to do a PHP job. What's the equivelant?
>
> I don't see any reason not to use PHP as the template language for PHP
> apps if one is disciplined in separating design from content. Or am I
> missing something here?

A proper templating system should be simpler and clearer than
embedding code, making it easier to seperate concerns. Of course PHP
as is meets most of those needs, but having templates as seperate
things rather than pointing at some PHP and saying 'thats a template',
and some other PHP and saying "that's code" should make organisation
easier.

> But then I'm still mastering TT, and thinking, why the heck didn't they
> just stick with embedded Perl, as I don't really want to master another
> syntax, and another language, just to write templates.
>
> On the other hand TT has some very nice features, which I don't think
> I've really mastered yet, I need to read more code written by people who
> know more about TT.

TT2 is much better suited to templating than embedded Perl. It
provides filtering, wrapping, loop variables for dealing with arrays
and/or hashes and tons of other stuff that make it work well.

I've been using it for rather a long time, but I think it's the mutt's
nuts, particularly after seeing and using HTML::Template (very strict,
very simple, very fast, but not powerful/flexible enough for me),
embperl, and a dozen inhouse templating systems (written in ASP, .Net
and PHP as well as Perl).

I don't think there is anything out there to match TT2 at what it
does, and TT3 will set the standard for the next generation of
templating systems.

> http://www.ukuug.org/events/linux2002/papers/html/php/#section_2
>
> "SMARTY" seems to be the most referenced, but I've never seen any in
> use. Most of the PHP I've seen hasn't been inspiring.

+1

Smarty seems to be the most common one I've seen, but I fear that
after TT and Perl, any PHP solution is going feel a bit pants.

A.

-- 
http://www.aarontrevena.co.uk
LAMP System Integration, Development and Hosting

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html