]> iEval git - gruntmaster-page.git/blobdiff - lib/Gruntmaster/Page/Pb/Entry.pm
Centralize template cooking and introduce reloadable templates
[gruntmaster-page.git] / lib / Gruntmaster / Page / Pb / Entry.pm
index c9dfe206b3f8aacd080c6fc5a2817088e6dca562..dbfbe18ca42b86c6c2f0b7fd3a6b21de6518b503 100644 (file)
@@ -7,18 +7,14 @@ use parent qw/Exporter/;
 our @EXPORT_OK = qw/generate/;
 our $VERSION = '0.001';
 
-use Fcntl qw/:flock/;
 use HTML::Template::Compiled;
-use IO::File;
 use POSIX qw/strftime/;
-use File::Basename qw/fileparse/;
-use Gruntmaster::Page::Common qw/header footer/;
+use Gruntmaster::Page::Common qw/cook_templates reload_templates/;
 use Gruntmaster::Data qw/contest_start contest_end problem_name problem_statement/;
 
 use constant FORMATS => [qw/CPP/];
-use constant TITLE => '<tmpl_var name>';
 
-my %templates = (
+my %orig_templates = (
        en => <<'HTML',
 <tmpl_var statement>
 
@@ -39,10 +35,10 @@ my %templates = (
 HTML
 );
 
-$templates{$_}  = header($_, TITLE) . $templates{$_} for keys %templates;
-$templates{$_} .= footer $_ for keys %templates;
+my %templates = cook_templates %orig_templates, pb_entry => '<tmpl_var name>';
 
 sub generate{
+       %templates = cook_templates %orig_templates, pb_entry => '<tmpl_var name>' if reload_templates;
        $_[0] =~ m,(?:ct/([^/])+/)?pb/(\w+)\.html$,;
 
        my ($contest, $id) = ($1, $2);
This page took 0.020515 seconds and 4 git commands to generate.