Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Template Toolkit compared to HTML::Template ( Re: Dynamically altering static TT templates)

by ViceRaid (Chaplain)
on Apr 05, 2002 at 09:10 UTC ( [id://156860]=note: print w/replies, xml ) Need Help??


in reply to Re: Dynamically altering static TT templates
in thread Dynamically altering static TT templates

Hi

I've worked quite a bit with both, and I think they're both excellent modules. However, they're quite different in style, and I think they're suited for different kinds of work. The main differences I can think of are:

  Template Toolkit HTML::Template
Template Syntax: More complicated, more "Perlish" control structures (keys, values...), and less immmediately HTML-ish (uses custom [% %] notation for template directives, although this can be changed). Simpler, and more HTML-ish at first sight (uses angle brackets <> and attributes).
Template Data Can work with hashrefs, objects using dot notation, and can pass the values back and forth as arguments. The final value in a dot sequence (foo.bar.thisone) could actually be a method call, or a hash key. Mainly intended to work with key-value pairs and lists of hashrefs. The VAR values are almost always (something like) hash keys.
Extensibility Easy to extend through the plugins mechanism, and exposes underlying function calls more obviously I wrote a substantial subclass of HTML::Template once ... it wasn't a nice experience. HTML::Template ties the mechanics of a template (reading it, parsing it, preparing it, replacing values) very closely to the implementation of specific template directives (LOOP, VAR, IF) and so on. The parser is a long regex which is trained to look specifically for the sequences like L-O-O-P V-A-R etc, so if you want to add a new tag, you have to rewrite the parser.

As I say, it's not a criticism of either. One of my clients uses an implementation of HTML::Template extensively. They edit the templates through the browser, the templates are stored in Oracle, and they love it, because all their (cheap) capable HTML-ers find it a doddle to work with. However, the pain factor, for me, of customising HTML::Template was pretty high.

Template Toolkit's syntax is a bit more scary for people used to vanilla HTML, and the overall flavour of using it is a lot more Perl-ish. But as it exposes more mechanics, it's much easier to customise it to interact with all kinds of different objects that might be relevant to your web application. This might make it a better choice for larger projects.

Horses for courses, I guess

//=\\
  • Comment on Template Toolkit compared to HTML::Template ( Re: Dynamically altering static TT templates)

Replies are listed 'Best First'.
Re: Template Toolkit compared to HTML::Template ( Re: Dynamically altering static TT templates)
by jerrygarciuh (Curate) on Apr 05, 2002 at 14:51 UTC
    Thank you so much for that comparison! Really helpful.
    jg
    _____________________________________________________
    Think a race on a horse on a ball with a fish! TG

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://156860]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-25 14:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found