Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

HTML::Template Tutorial

by jeffa (Bishop)
on Mar 20, 2001 at 11:07 UTC ( #65642=perltutorial: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
    use HTML::Template;
    my $template = HTML::Template->new(filename => 'secret.tmpl');
    $template->param(SECRET_MESSAGE => $bar);
    print $template->output;
  2. or download this
    <!-- secret.tmpl -->
  3. or download this
    <!-- secret2.tmpl -->
       SECRET_MESSAGE => 'There is no Perl Illuminati',
    print $template->output;
  4. or download this
    <!-- secret2.tmpl -->
    my $template = HTML::Template->new(filename => 'secret2.tmpl');
    $template->param(SECRET => $message);
    print $template->output;
  5. or download this
    <!-- students.tmpl -->
    print $template->output;
  6. or download this
    <!-- songs.tmpl -->
  7. or download this
    push @{$rows}, $_ while $_ = $sth->fetchrow_hashref(); 
  8. or download this
       'artist' => 'Van Halen',
       'album'  => 'Van Halen II',
       'year'   => '1979',
  9. or download this
    # we don't need no stinkin' column names
    my $rows = $DBH->selectall_arrayref('select * from songs');
        die_on_bad_params => 0,
    $template->param(ROWS => $rows);
  10. or download this
    my $CGI       = CGI->new();
    my $template  = HTML::Template->new(
       filename  => 'foo.tmpl',
       associate => $CGI,
  11. or download this
    <!-- pill.tmpl -->
       loop_context_vars => 1,
    # etc.
  12. or download this
    my $template = HTML::Template->new(scalarref => \$scalar);
  13. or download this
    #!/usr/bin/perl -Tw
    use DBI;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://65642]
[thezip]: G'day all!
[perldigious]: Well, that and dodging the people who forget how ice works right away. :-)
[stevieb]: hey, thezip
[perldigious]: I don't miss having to drive up and down in elevation on roads that are iced over, I white knuckled gripping the steering wheel every time I had to where I used to live.
[perldigious]: So I don't envy you mountain guys if you have to drive in the winter, even with tire chains.
MidLifeXis waves.
[stevieb]: man, I absolutely LOVE driving in the worst winter conditions. In the mountainous roads, there are extremely few (if any) other drivers. I love the challenge. I've been doing extreme off-road my whole life, and as I said, I'm always well...
[stevieb]: ...prepared for even the very worst
Discipulus seems a part of the globe very unfrindly with Kawasaki riders..

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2016-12-06 16:46 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (112 votes). Check out past polls.