diff --git a/site-generator b/site-generator index 8793909..612a5f2 100755 --- a/site-generator +++ b/site-generator @@ -37,6 +37,7 @@ use warnings; use Getopt::Long qw(:config auto_help); use Pod::Usage; use Config::Std; +use Template; exit main(); @@ -53,9 +54,36 @@ sub main { # Load config file read_config "site.cfg" => my %config; - use Data::Dumper 'Dumper'; - warn Dumper [ \%config ]; + my $tt = get_template_html(); + generate_page($tt, $config{contact}{navigation}, $config{contact}{content}); 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 => '', + }) || 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"; + +} +