forked from rho_n/hpr_generator
Initial ability to generate page from config file
Added a function to facilitate looping through a list of pages to be generated. Currently hard coded the generation of the contact page based on the site.cfg file.
This commit is contained in:
parent
b66ea3fd69
commit
e31c4a2208
@ -37,6 +37,7 @@ use warnings;
|
|||||||
use Getopt::Long qw(:config auto_help);
|
use Getopt::Long qw(:config auto_help);
|
||||||
use Pod::Usage;
|
use Pod::Usage;
|
||||||
use Config::Std;
|
use Config::Std;
|
||||||
|
use Template;
|
||||||
|
|
||||||
exit main();
|
exit main();
|
||||||
|
|
||||||
@ -53,9 +54,36 @@ sub main {
|
|||||||
# Load config file
|
# Load config file
|
||||||
read_config "site.cfg" => my %config;
|
read_config "site.cfg" => my %config;
|
||||||
|
|
||||||
use Data::Dumper 'Dumper';
|
my $tt = get_template_html();
|
||||||
warn Dumper [ \%config ];
|
generate_page($tt, $config{contact}{navigation}, $config{contact}{content});
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub get_template_html {
|
||||||
|
|
||||||
|
# For an HTML based Template file, define the
|
||||||
|
# template start and end tags to also function as
|
||||||
|
# HTML comments to make the template file valid HTML.
|
||||||
|
#
|
||||||
|
return Template->new({
|
||||||
|
INCLUDE_PATH => './templates',
|
||||||
|
EVAL_PERL => 1,
|
||||||
|
START_TAG => '<!--%',
|
||||||
|
END_TAG => '%-->',
|
||||||
|
}) || die $Template::ERROR, "\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sub generate_page ($tt, $navigation, $content) {
|
||||||
|
my ($tt, $navigation, $content) = @_;
|
||||||
|
my $tt_vars = {
|
||||||
|
navigation => $navigation,
|
||||||
|
content => $content
|
||||||
|
};
|
||||||
|
|
||||||
|
$tt->process('page.tpl.html', $tt_vars)
|
||||||
|
|| die $tt->error(), "\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user