in reply to Generating an HTML survey form from simple markup

o/` What the world needs now / is another Perl Templating module / like I need a hole in my head o/`

I'd either use one of the plethora of existing templating modules (TT2 or what not) to define your survey markup, or if you're looking for something more programmatic then use YAML as the format, let it do the heavy lifting for the parsing, and then run over the structure that produces making calls to CGI::FormBuilder.

action: /somepath/survey.cgi fields: - type: text name: Name width: 30 - type: radio name: Gender choices: [ Male, Female ]

(Now I have to go hide before Bob Mould's Cracker's lawyers come to beat me up . . .)

Update: Tweaked the YAML formatting. And I misremembered the lyric reference (Sugar, Cracker, tomayto, tomahto)

Replies are listed 'Best First'.
Re^2: Generating an HTML survey form from simple markup
by jZed (Prior) on Feb 03, 2005 at 17:02 UTC
    Yes, for sure, templating modules will be used. If this is a front end for CGI::FormBuilder, it can send it's output to HTML::Template, Text::Template, etc. My module shouldn't mess with presentation *at all*.

    Yes, I considered YAML, but compare the legibility of your example to mine. Too much typing!

      Yes, I considered YAML, but compare the legibility of your example to mine. Too much typing!

      But the YAML is self documenting. You can tell exactly what each parameter that's being set; with positional parameters you have to remember the right order. If that's too chatty for you you could still use positional parameters and let YAML parse it.

      action: '/somepath/foo.cgi' fields: - [ text, name, "Your name:" ] - [ radio, gender, Male, Female ] - [ textarea, complaints, "Enter your complaints here", 80, 24 ]
        I get your point, and for many uses, I'd agree. I may yet go with YAML. One issue is that I'd like this to optionally be part of a pod document - I'll first run Pod::HTML on the text file, then parse the form fields into HTML within that generated document. This will allow the text file to contain things like survey section headings and commentary paragraphs. I'm not sure that would integrate too well with YAML (though I suppose I could mark YAML sections and parse them separately). Maybe by describing my audience as "non-techies" I was misstating my goal. My first goal is to make this something that I can quickly whip up a survey by making the simplest possible podfile and generating from that.