header.html
[% title %]
[% title %]
***********************************************
footer.html
[% copyright %]
***************************************************
main.html
[% PROCESS header title="Some Interesting Links" %]
Here are some interesting links:
[% PROCESS footer %]
***************************************************
process_template.pl
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
use strict;
use warnings;
use Template;
# create template processor
my $tt = Template->new({
INCLUDE_PATH => [ '/home/userone/public_html/template',
],
PRE_PROCESS => 'header',
POST_PROCESS => 'footer',
});
# define data
my $data = {
copyright => '© 2002 Andy Wardley',
weblinks => [
{
url => 'http://perl.apache.org/',
title => 'Apache/mod_perl',
},
{
url => 'http://tt2.org/',
title => 'template Toolkit',
},
]
};
$tt->process('main.html',$data) || die $tt->error();
********************************