]> iEval git - gruntmaster-page.git/blobdiff - lib/Gruntmaster/Page/Ct/Entry.pm
Centralize template cooking and introduce reloadable templates
[gruntmaster-page.git] / lib / Gruntmaster / Page / Ct / Entry.pm
index 3c336c17bd0939c7b36460194b1a831b76a3972d..bba2991c6e8a13d5fbeebbd473cbd440cb2806a4 100644 (file)
@@ -7,14 +7,12 @@ use parent qw/Exporter/;
 our @EXPORT_OK = qw/generate/;
 our $VERSION = '0.001';
 
-use constant TITLE => '<tmpl_var name>';
-
 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/;
 
-my %templates = (
+my %orig_templates = (
        en => <<'HTML',
 Contest start time: <tmpl_var start><br>
 Contest end time: <tmpl_var end><p>
@@ -25,10 +23,10 @@ Contest end time: <tmpl_var end><p>
 HTML
 );
 
-$templates{$_}  = header($_, TITLE) . $templates{$_} for keys %templates;
-$templates{$_} .= footer $_ for keys %templates;
+my %templates = cook_templates %orig_templates, ct_entry => '<tmpl_var name>';
 
 sub generate{
+       %templates = cook_templates %orig_templates, ct_entry => '<tmpl_var name>' if reload_templates;
        my ($path, $lang) = @_;
        $path = ($path =~ m,ct/(.*)/index,)[0];
        my $template = $templates{$lang};
This page took 0.025959 seconds and 4 git commands to generate.