]> iEval git - gruntmaster-page.git/blobdiff - lib/Gruntmaster/Page/Ct.pm
Centralize template cooking and introduce reloadable templates
[gruntmaster-page.git] / lib / Gruntmaster / Page / Ct.pm
index 19c4aad33cc319d4504768eb2b7fc8c30c4ac47a..8ef38155306fe9b42ec55e92089b04a6a5282086 100644 (file)
@@ -7,14 +7,12 @@ use parent qw/Exporter/;
 our @EXPORT_OK = qw/generate/;
 our $VERSION = '0.001';
 
-use constant TITLE => 'Contests';
-
 use HTML::Template::Compiled;
 use POSIX qw/strftime/;
-use Gruntmaster::Page::Common qw/header footer/;
+use Gruntmaster::Page::Common qw/cook_templates reload_templates/;
 use Gruntmaster::Data qw/contest_name contest_start contest_end contest_owner/;
 
-my %templates = (
+my %orig_templates = (
        en => <<'HTML',
 <tmpl_if running>
 <h1>Running contests</h1>
@@ -60,10 +58,10 @@ my %templates = (
 HTML
 );
 
-$templates{$_}  = header($_, TITLE) . $templates{$_} for keys %templates;
-$templates{$_} .= footer $_ for keys %templates;
+my %templates = cook_templates %orig_templates, ct => 'Contests';
 
 sub generate{
+       %templates = cook_templates %orig_templates, ct => 'Contests' if reload_template;
        my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$_[1]});
 
        my (@running, @pending, @finished);
This page took 0.019209 seconds and 4 git commands to generate.