cosmicperl has asked for the wisdom of the Perl Monks concerning the following question:

Hi All,
  I'm working on a new plugin for CGI::Application. It generates HTML forms based on a HTML::Template file, but creating each input field from YAML schema.

At the moment I'm using CGI.pm to generate the input fields. The problem is I know a lot of people use CGI::Simple with CGI::Application so the HTML generation isn't always available.

I've considered an option of using HTML::Template::Set to get sample input field HTML into the script. But I also want the option to be able to just define some styles in the YAML and generate the input field HTML from the script.

I read a lot of people saying never use CGI.pm to generate HTML, so what is the alternative? Should I just roll my own HTML? Or is there another module I should be using?


Lyle

Update: Just found HTML::EasyTags which is perfect!

Replies are listed 'Best First'.
Re: Generating HTML- CGI.pm - CGI::Simple
by wfsp (Abbot) on Mar 11, 2009 at 07:59 UTC
    I use CGI::Application with CGI::Simple and HTML::Template and I find it works very well.

    I may be missing something but couldn't you combine the two?

    my $t = HTML::Template->new(filename => q{tmpl.html}); $t->param( input_field => get_input_field(), ); print $t->output; sub get_input_field{ # do something with YAML }
    <html> ... <TMPL_VAR input_field> ... </html>
      That's what I'm doing :) Just that in your example get_input_field would load the YAML then use CGI.pm to make the input field.

      I think I'll just roll my own unless I come across something lightweight on CPAN.


      Lyle