Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

HTML::Template - Loop under Division Problem

by monkfan (Curate)
on Apr 04, 2007 at 03:32 UTC ( [id://608198]=perlquestion: print w/replies, xml ) Need Help??

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

Dear experts,
With the given template, I can sucessfully generate the html page with loop inside. The final output of the html generated with that template is here
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w +3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <html><body bgcolor = white font = garamond><head><title>Your SPACE We +b Results</title></head> <link rel="stylesheet" type="text/css" href="../css_scripts/nactem.cs +s" /> <body> <span style='font-size:12.0pt;font-weight:bold;font-family:courier,gar +amond,arial,sans-serif;color:black;'> ============ BEST MOTIF SEEMS TO BE: =============<br> MOTIF: <b> <TMPL_VAR NAME=MOTIF> </b> <p> REDUNDANT Motifs are: <br> <TMPL_VAR NAME=REDDM> <br> Significance Score: <TMPL_VAR NAME=SIGSC> <br> <TMPL_LOOP NAME="LOOP1"> <TMPL_VAR NAME="INST"> <br> </TMPL_LOOP> <p> <img src="<TMPL_VAR NAME=FIG>"> <br> <br> <HR> </body> </html>
But when I use the following template (using CSS and div):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w +3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!-- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en +"> --> <html> <head> <title></title> <meta name="copyright" content="&copy; National Centre for Text Mini +ng" /> <link rel="schema.DC" href="http://purl.org/dc/elements/1.1/" /> <link rel="schema.DCTERMS" href="http://purl.org/dc/terms/" /> <meta name="DC.title" content="Acromine Demonstration" /> <meta name="DC.creator" content="Naoaki Okazaki" /> <meta name="DC.publisher" content="NaCTeM" /> <meta name="DC.type" content="XHTML" /> <meta name="DC.format" content="text/html;charset=iso-8859-1" /> <meta name="DC.language" scheme="DCTERMS.URI" content="English" /> <link rel="stylesheet" type="text/css" href="../css_scripts/nactem.cs +s" /> <link rel="stylesheet" type="text/css" href="../css_scripts/chokka +n.css" /> <link rel="up" href="/" title="Up" /> <link rel="up" href="/" title="Up" /> <style type="text/css"> <!-- .style1 {font-size: small} .style2 { font-size: 18px; font-weight: bold; font-family: Arial, Helvetica, sans-serif; } --> </style> </head> <body> <div id="container"> <!-- MAIN CONTENT --> <!--<div id="content"> --> <div id="pagecontent"> <div id="subcontent" style="position: absolute; height: 1621px; widt +h: 812px; left: 0px; top: 45px;"> <div align="left"> <p><span class="style2">SPACE - Results </span></p> <p> MOTIF: <b> <TMPL_VAR NAME=MOTIF> </b> <p> REDUNDANT Motifs are: <br> <TMPL_VAR NAME=REDDM> <br> Significance Score: <TMPL_VAR NAME=SIGSC> <br> <TMPL_LOOP NAME="LOOP1"> <TMPL_VAR NAME="INST"> <br> </TMPL_LOOP> <p> <img src="<TMPL_VAR NAME=FIG>"> <br> <br> <HR> </p> </div> <div style="position: absolute; width: 812px; height: 57px; z-inde +x: 1; left: 0px; top: 1565px; background-color: #FFFBE1; text-align: +left;" id="layer"> <p align="center"><font size="5"><br /> </font> <span class="style1">All Site Content Copyright of NUS (2 +007) </span><font size="5"><strong><br /> &nbsp;</strong><br /> </font></p> </div> </div> <div style="position: absolute; width: 812px; height: 113px; z-index: +1; left: 0px; top: -66px; background-color: rgb(255, 255, 255); text- +align: left;" id="layer1"> <p><font size="5"><img src="../image/nuslogo.gif" alt="" hspace="8" al +ign="baseline" style="width: 139px; height: 63px; float: right;" /> & +nbsp;<strong><br /> &nbsp; National University of Singapore<br /> <br /> &nbsp; School of Computing </strong></font><font size="5"><strong>- Bi +oinformatics Lab</strong></font></p> <hr /> <p><font size="5"><br /> </font></p> </div> </div> </div> </div> <!-- END PAGE CONTAINER --> </body> </html>
It fails to generate the result of on other loops (prints only 1 entry). As can be seen in this ouput. And the portion of my Perl script that call HTML::Template is this:
#!/usr/bin/perl -w use HTML::Template; # For the sake of clarity # I have removed some unnecessary variables # Printing them my $cnt; foreach my $mset (@motif_set) { $cnt++; if ( $cnt == 1 ) { my $template = HTML::Template->new( filename => 'fail_temp +late.tmpl' ); #my $template = HTML::Template->new( filename => 'success_ +template.tmpl' ); $template->param( MOTIF => change_motif_to_iupac($mot) ); $template->param( REDDM => $redstrs); $template->param( SIGSC => $wscr); my @loopdata; foreach my $inst ( @inset ) { my %row_data; # get a fresh hash for the row data $row_data{INST} = $inst; push (@loopdata, \%row_data); } $template->param(LOOP1 => \@loopdata); $template->param( FIG => $wln1 ); print OUTFILE $template->output; } else { my $template2 = HTML::Template->new( filename => 'fail_tem +plate.tmpl' ); #my $template2 = HTML::Template->new( filename => 'success +_template.tmpl' ); $template2->param( MOTIF => change_motif_to_iupac($mot) ); $template2->param( REDDM => $redstrs2); $template2->param( SIGSC => $wscr2); my @loopdata2; foreach my $oinst ( @oinset ) { my %row_data2; # get a fresh hash for the row data $row_data2{INST} = $oinst; push (@loopdata2, \%row_data2); } $template2->param(LOOP1 => \@loopdata2); $template2->param( FIG => $wln2 ); print OUTFILE $template2->output; } } close ( OUTFILE ); # close output file system("chmod a+x $outfile");
Is there any special requirement for HTML::Template to work under <div>? What went wrong with my scheme above?

Regards,
Edward

Replies are listed 'Best First'.
Re: HTML::Template - Loop under Division Problem
by Anonymous Monk on Apr 04, 2007 at 03:43 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-19 21:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found