[Analysis] Templates: The good, the bad, the ugly

J. Paul Reed preed at sigkill.com
Mon Dec 13 23:34:38 UTC 2004


On 13 Dec 2004 at 15:17:08, Myk Melez arranged the bits on my disk to say:

> J. Paul Reed wrote:
> 
> >Or, put another way: we could've used something lighter weight than
> >Template Toolkit.
> 
> Sure, but could we have used something better?  I don't think so.

Yet, you really don't provide any justification for that answer. 

I was having a conversation with Christopher Hicks about this, and I
provided a lighter weight solution which I think is better.

Of course, I didn't bother mentioning it here because a) I wrote it, so "of
course I think it's better" and b) I wrote it long after TT was chosen.

Personally, I think TT is a huge pile of crap, if for no other reason than
it's slow. But, it's what was chosen and it's what we're using.

That doesn't mean that we shouldn't do a post-mortem and be honest about
where the policy decisions, implementation efforts and the technology
failed. We should be similarly honest about the successes.

Also, the claim "We shouldn't look at any other solutions now because the
one we picked years ago was the best one at the time" isn't compelling. I
don't know if you're making that claim, but I've heard it made, and that's
just wrong.

> The other two options are a specialized template language like TT and
> embedding Perl in HTML.  Are you suggesting that the latter approach
> would be better than TT's specialized language?

Yes, although note that I said that approach makes more sense in PHP; it's
highly debatable in Perl (I can see both sides), and that's why I didn't
really involve myself in the discussion on the matter.

> I wouldn't recommend this approach, however, primarily because TT's
> specialized language is much easier to use than pure Perl code for common
> template tasks, and learning it is simply not a significant burden
> compared to the increases in productivity and programming pleasure it
> provides.

This is your own personal judgment call. Some may agree with you.

Me, I didn't find using TT "pleasurable" at all. I found it's loop control
particularly stupid.

> >Also, there are some templates that use callbacks to call back into
> >perl-code to do more work; when mail gets sent, this happens.
> >
> >It's ugly and should be replaced
> 
> This is actually the right thing to do in some cases, particularly when
> processing takes a while and we can give the user updates on its
> progress, f.e. when sending mail or modifying multiple bugs.  Of course,
> we would need iterative template output for that, but that can be hacked
> into TT2 and comes native in TT3, an alpha of which was recently
> released.

Ahh... the software salesman's mantra: "It's in the next version."

Either way, that way it's done now is ugly, and problematic because of
include ordering.

It was amusing for the first half hour I dealt with it; then I didn't find
it so amusing.

Later,
Paul
------------------------------------------------------------------------
J. Paul Reed -- 0xDF8708F8 || preed at sigkill.com || web.sigkill.com/preed
Math, my dear boy, is nothing more than the lesbian sister of biology.
                                            -- Peter Griffin, Family Guy

I use PGP; you should use PGP too... if only to piss off John Ashcroft



More information about the developers mailing list