Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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'

Comment on Re: HTML::Template Vs Template Toolkit

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2015-11-25 00:40 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (666 votes), past polls