HTML::WTweb - A simply and relatively efficient HTML template system.
use HTML::WTweb; my $WT = HTML::WTweb->new(); $WT->sethtmldir("./html"); $WT->fileload("test1.html","test2.html"); $WT->processhtml(FileName => "test1.html", Header => 1, -title => "hello universe", -ptag => "citzens of the sky"); my @planets = ("venus", "mars", "jupiter"); foreach my $p(@planets){ $WT->processhtml(FileName => "test2.html", -planet => $p); } undef $WT;
Where test1.html and test2.html are something like this:
<head> <title>-title</title> </head> <p>here are the -ptag</p>
and <p>I came here from -planet</p>
Methods:
sethtmldir: sets the directory where html template files are placed.
fileload: load one or more template from htmldir.
processhtml: operate the parsing, substitutions and output to stdout of the given template.
I suggest you to use CGI module instead my poor "Header" switch to print out canonical header if you also need to retrieve form parameters from a previous post.
The directory where html templates are stored should be ./html, I haven't tried to put them elsewhere
/usr/local/apache/myweb <- perl code
/usr/local/apache/myweb/html <- html templates
This module must be interpretated as a preliminary release of a more complete package suite. Using WTweb make easy to detach the crummy html tags from the beauty of perl, in a simply and synthetic way. It won't be the top of efficiency, but it's simply and intended to reliate headache arised from the tedious web applications. It may also used as generic text-template system.
Gian Maria Gamboni <gmg@cpan.org>
Copyright (c) 2005 Gian Maria Gamboni - All Rights Reserved This code is free software and you may redistribuite or modify it under the same terms as Perl itself.
To install HTML::WTweb, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::WTweb
CPAN shell
perl -MCPAN -e shell install HTML::WTweb
For more information on module installation, please visit the detailed CPAN module installation guide.