Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Thanks Maverick, it is becoming more clear to me now ;). To prove the point, here's an excerpt from an app I'm now building:

File: main.cgi
#!/usr/local/bin/perl -w use strict; use HTML::Template; ################################### ## includes ################################### use XCGI; require "config.pl"; ################################### ## MAIN ################################### my $cgi = new XCGI; # my version of CGI (with a few subs added/redefin +ed). print $cgi->header(); my $template = new HTML::Template(filename => "$CONFIG::template_root/ +main.tmpl", die_on_bad_params => 0); $template->param( select_box_datasource => $cgi->select_list(-name=>'s_dns', -values=>[keys(%CONFIG::ds_info)], -labels=>{sh=>\%CONFIG::ds_info, so +urce_key=>'info'}, -default=>['webdb'], -size=>1), ); print $template->output();

File: templates/main.tmpl
<html> <title>Automation Tool</title> <body> <form> <table border=1 > <tr> <td> Select Datasource: <TMPL_VAR NAME="select_box_datasource"> <br> </td> </table> </form> </body> </html>
Note that select_box_datasource variable will hold a piece of custom built html similar to this:
<SELECT NAME="s_dns" SIZE=1> <OPTION VALUE="foo">Production <OPTION SELECTED VALUE="foobar">Development <OPTION VALUE="bar">Development 1 </SELECT>

the select_list() subroutine is implemented (overwritten) inside XCGI module which serves as my (custom) extension to standard CGI. Although, CGI has a similar subroutine, it didn't fit the needs of my application (as seen from the code...).


"There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith

In reply to Re: Q / A and HTML::Template techniques... by vladb
in thread Q / A and HTML::Template techniques... by maverick

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2021-10-26 06:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (90 votes). Check out past polls.

    Notices?