Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (14)
As of 2014-09-23 15:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (227 votes), past polls