http://www.perlmonks.org?node_id=995332


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'