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:
@@ -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";
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user