Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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
    # secret.pl
    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 -->
    <h1>Hello <TMPL_VAR NAME=SECRET_MESSAGE></h1>
    
  3. or download this
    <!-- secret2.tmpl -->
    <TMPL_IF NAME="ILLUMINATI">
    ...
       SECRET_MESSAGE => 'There is no Perl Illuminati',
    );
    print $template->output;
    
  4. or download this
    <!-- secret2.tmpl -->
    <TMPL_IF NAME="SECRET">
    ...
    my $template = HTML::Template->new(filename => 'secret2.tmpl');
    $template->param(SECRET => $message);
    print $template->output;
    
  5. or download this
    <!-- students.tmpl -->
    <TMPL_LOOP NAME=STUDENT>
    ...
       ]
    );
    print $template->output;
    
  6. or download this
    <!-- songs.tmpl -->
    <html>
    ...
    
    
    $DBH->disconnect();
    
  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 -->
    <table>
    ...
       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;
    ...
    
    </body>
    </html> 
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2015-07-07 12:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls