Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Q / A and HTML::Template techniques...

by vladb (Vicar)
on Dec 20, 2001 at 07:53 UTC ( [id://133396]=note: print w/replies, xml ) Need Help??


in reply to Q / A and HTML::Template techniques...

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://133396]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2024-04-18 12:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found