[Templates] Template Tookit Vs HTML::Template

Sea Bass seabass@pobox.com
Sun, 17 Nov 2002 14:20:47 +0000


Quoting Curtis Poe <cp@onsitetech.com>:

> ----- Original Message -----
> From: "Rafiq Ismail (ADMIN)" <rafiq@joshua.dreamthought.com>
> > I have to provide sound arguments as to why our prospective new system
> > shouldn't move away from TT2 and use HTML::Template instead.
> 
> Not to douse your evangelical fire :), but I suggest stepping back a bit.
> HTML::Template is great.  Pro/Con arguments, however, can quickly get bogged
> down in minutia and miss the point:  what are your requirements?  The choice
> should never be 'what do I prefer?'  The choice is more accurately 'what is
> the better tool for the job?'
> 

Exactly.  However, I can't resist making a couple points. (These points were
important to us, they may not be to you.)

1) You can display regular old business objects directly using TT.  Business
entites, such as "Employee" or "Account" can be represented as objects with
accessors ("getters") so that their data can be displayed in a template.

[%FOREACH employee = employeesToDisplay %]
$employee.name - $employee.phoneNumber
[%END%]

For us, our business objects know nothing about how they are persisted, so the
ability to access these objects from a template can hardly be abused. Plus, the
template author can only access the business objects that you (the perl coder)
place in the template, so you have complete control. 

These same business objects can be used in many other contexts besides a web
application.  For us, this is a big advantage, maybe it isn't for you.

I've heard people say that the ability to access objects directly breaks "MVC"
separation.  I'm not sure what MVC they are talking about, because in
Smalltalk's MVC allowing "View" code to query "Model" objects is a necessary
part of the pattern.

2) TT syntax is orthagonal to HTML/XML.  I like having template code stand out
from my HTML/XML code.  After all, their purposes are very different.

regards,
seabass