in reply to HTML::Template vs. CGI.pm

I know this is not comme-il-faut, but I have increasingly come to detest templating toolkits myself. If you can get your HTML-monkeys to maintain your templates for you, they're probably great. However, I suspect this is quite often a red herring. At least of I the projects I do involving web stuff only a very few come with ready-to-use HTML-monkeys at my beck and call. And if I still have to maintain my templates myself, why, oh why, should I maintain them in the unholy format that is HTML? And passing data to a templating toolkit -- don't get me started. You either adjust your wonderful controller code the the templating toolkits idea of control and data structures with a sledgehammer, or you (shudder) embed Perl code in your HTML templates.

(I detest CGI.pm, too, it's not just templating toolkits. It's one of the things I'm good at. Detesting.)

Lately, I've started to tinker with doing HTML in Perl. It's rather fun, actually. I do thinks like:

body { div { { class => 'content' }, q{Text content}, table { { width => '100%' }, row { cell { ... }, cell { ... } } } } }
While I can still separate controller and view, now I'm able to code my view in a sensible syntax, and I can pass stuff back and forth without feeling cuffed and gagged. This is still an experiment, so I'm not sure if it's really a good idea, but it's refreshing.

(Ok, so this doesn't really answer your question at all. Sice the templating guys are bound to do so though, I just thought I'd share. Sorry.)

Replies are listed 'Best First'.
Re: Re: HTML::Template vs. CGI.pm
by perrin (Chancellor) on Nov 11, 2003 at 00:40 UTC
    It's been many years since I worked on a project where the HTML was done by the programmers, and I would still prefer templates for various reasons. However, if generating HTML programmatically is your bag, you might like higher-level abstractions like what Bivio does.

    I think you're exaggerating the part about needing to change your data format. Template Toolkit can deal with pretty much any data structure you pass in, and doesn't need in-line Perl to do it.

      I think you're exaggerating the part about needing to change your data format. Template Toolkit can deal with pretty much any data structure you pass in, and doesn't need in-line Perl to do it.
      You're right, that was unfair. Still, you end up catering to templating toolkits' notion of control structures no matter what, be they rigidly formatted data structures or a separate specialized in-line language. I'd like to code my control structures in Perl.
        I don't really see where you're getting this from. If you want to code your control structures in Perl, in-line Perl systems let you do exactly that. The only popular templating tool that imposes restrictions on your data structure is HTML::Template, and even there I find them pretty easy to work within.

        There is definitely room in the world for programmatic generation of HTML. You don't need to drag down templating in order to prove the value of your approach.