[Catalyst] Re: template comparison (was: why not mason

Perrin Harkins perrin at elem.com
Wed Nov 1 18:25:32 GMT 2006


On Wed, 2006-11-01 at 17:17 +0100, A. Pagaltzis wrote:
> * Perrin Harkins <perrin at elem.com> [2006-10-28 06:05]:
> > You're only supposed to use the TT language for simple things.
> > Hairy things are supposed to be encapsulated in plugins,
> > written in Perl.
> 
> That makes a certain amount of sense; I say a certain amount,
> because I’m not sure what case it makes for TT2:

I'm not trying to make a case for TT2.  Some people will prefer other
things, and I personally use different systems on different projects.
I'm just advising that people who use TT2 would be better off if they
avoid trying to code complex logic in the TT2 mini-language.

> 1. Some bits of hairy display logic really are specific to the
>    particular template they’re in, so putting them in a plugin
>    just pointlessly moves apart related bits of code.
>    
> 2. Sometimes there are still large blocks of static strings
>    interspersed with such logic, so it’s more of a sub-template
>    task than a plugin task.

TT provides multiple ways to make sub-templates, which can take
parameters.  If you have some code that's really single-use and you want
to keep it in the template, you could use an in-line perl section in an
included template for that one bit.

Personally, I would use a plugin anyway, because the tools (debugger,
profiler, etc.) work a lot better on a perl module than on a template
with in-line code, and the code is easier to test.

> 3. If you’re going to bail out to the Perl layer for complex
>    stuff (which you should), you might as well pick something
>    with a more concise markup generation syntax than TT2’s for
>    the simple stuff. (I admit TT2 fares decently when producing
>    plain text formats – but I’ve never had to do that.)

Something with fewer keywords, you mean?  What would that be?
HTML::Template?  I think the additional abstraction for data access that
TT provides usually makes for simpler templates and avoids needing to
code a lot of repetitive data copying in perl, and the plugin support
makes it a lot easier to deal with formatting dates and numbers and
handling multi-column lists.  I'd be perfectly happy to see TT remove
some of the current keywords, but the things I don't use don't really
cause any problems for me.

- Perrin




More information about the Catalyst mailing list