in reply to Re: working with templates
in thread working with templates

hi,
Thanks for your response. I can't get it to work. But I'll keep trying. Just checking about the template file. Should I put some code to let HTML::Template know which template I want to use? eg.
my $template = HTML::Template->new( filename => 'indexpag2.tpl', loop_context_vars => 1 );

Replies are listed 'Best First'.
Re^3: working with templates
by GertMT (Hermit) on Apr 24, 2007 at 20:32 UTC
    alright thanks it works:
    #!/usr/bin/perl -w use strict; use diagnostics; use Data::Table; use HTML::Template; open( OUT, ">itworks.html" ) or die "cant open out $!"; my $table = new Data::Table( [ [ 1, 2, 3 ], [ 10, 20, 30 ] ], [ 'A', ' +B' ], 1 ); my @newCol2 = (); $newCol2[ $table->nofRow - 1 ] = undef; # print $table->html; my $template = HTML::Template->new( filename => 'template.tpl' # loop_context_vars => 1, # filter => \&cstmrow_filter ); $template->param( my_table => $table->html ); print OUT $template->output;
    template.tpl
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" +> <title>It Works</title> <meta name="generator" content="TextMate http://macromates.com/"> </head> <body bgcolor="silver"> <center> <h1 id="just_a_sample_table">Just a sample table</h1> <tmpl_var name="my_table"> <pre>2007-04-24</pre> &copy; ... ; ) </center> </body> </html>
    THANKS!