in reply to Re: Re (tilly) 2: OO CGI vs. function-oriented
in thread OO CGI vs. function-oriented

A proper templating module will allow you to do all these things very easily. HTML::Template even which in my opinion is far from the be-all end-all templating module can be tied to CGI to provide the same value defaulting of form elements that CGI offers with its HTML generation functions.

I consider an immense benefit of templates that the algorithmic logic of the application is never influenced by any output format concerns, the values just get stuffed into a data structure and the template pulls them out at will. For example, let's say I suddenly choose to change the display of a table of records to show the records vertically, rather than horizontally. All I have to do is change the template.. which is bound to be quicker than changing code to accomodate for this would be because a good templating language is geared towards data presentation - a specialized tool for a specific job.

And if you want the installation ease a single module provides, there is nothing to stop you from storing the templates eg. as values in a hash. You might do something like my $templates = do "templates.pl";, where templates.pl contains { a => 'single', anonymous => 'hash' } block.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: Re: Re (tilly) 2: OO CGI vs. function-oriented
by shotgunefx (Parson) on Jan 29, 2002 at 00:45 UTC
    For most people and applications, templates are fine. In my situation it wouldn't work. The forms parameters themselves are mangled on the fly in such a way, that I would have to make my own parser (or use an existing one), and then create another layer to perform our magic. If I need to make a change to the HTML, it takes me a minute using an HTML to CGI.pm converter so changes are almost as fast.

    Anyway, the point is it doesn't always make sense and TMTOWTDI.

    -Lee

    "To be civilized is to deny one's nature."