Archived
4
2

Configure database connection in config file

Pass the db configuration info to the page templates via the
template constants feature.
This commit is contained in:
2022-06-29 10:42:10 -04:00
parent b33e812c3d
commit 3d0ddbfe24
2 changed files with 15 additions and 3 deletions

View File

@@ -54,14 +54,13 @@ sub main {
# Load config file
read_config "site.cfg" => my %config;
my $tt = get_template_html();
my $tt = get_template_html($config{DBI});
generate_page($tt, $config{correspondents}{navigation}, $config{correspondents}{content});
return 0;
}
sub get_template_html {
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.
@@ -71,6 +70,11 @@ sub get_template_html {
EVAL_PERL => 1,
START_TAG => '<!--%',
END_TAG => '%-->',
CONSTANTS => {
driver => $_[0]{driver},
user => $_[0]{user},
password => $_[0]{password},
}
}) || die $Template::ERROR, "\n";
}