Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: HTML::Template Vs Template Toolkit

by tobyink (Abbot)
on Sep 24, 2012 at 09:48 UTC ( #995332=note: print w/replies, xml ) Need Help??

in reply to HTML::Template Vs Template Toolkit

A variant of Greenspun's tenth rule says that any sufficiently mature HTML template language becomes a clunky, ad-hoc variant dialect of its host language. Smarty exposes pretty much all the power of PHP with an even dumber syntax. TT2 does the same for Perl.

This is what I don't "get" about template languages. If I want to write my templates in something Turing-complete, then why would I want to learn and use the clunky, ad-hoc language? Why not just write my template in Perl, a language that I already know?

This is what I like about Text::Template, and why I choose it over TT2 and friends on the rare occasions I actually need templates. Rather than inventing a new template language, it simply provides a mechanism for embedding Perl in strings, and evaluating those strings.

More often though, if I'm outputting HTML rather than treating it as templated text, I tend to prefer to build it up as a DOM tree and then serialize it.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://995332]
and a kettle whistles...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2018-05-27 22:11 GMT
Find Nodes?
    Voting Booth?