]> iEval git - plack-app-gruntmaster.git/blobdiff - lib/Gruntmaster/Page/Pb.pm
Centralize template cooking and introduce reloadable templates
[plack-app-gruntmaster.git] / lib / Gruntmaster / Page / Pb.pm
index 5ada0e22b8a5ad07175140b570a299d33384cdb1..18b47bf894710cb8449ba68910592c7a1a266004 100644 (file)
@@ -7,16 +7,14 @@ use parent qw/Exporter/;
 our @EXPORT_OK = qw/generate/;
 our $VERSION = '0.001';
 
-use constant TITLE => 'Problems';
-
 use Fcntl qw/:flock/;
 use HTML::Template::Compiled;
 use IO::File;
 use POSIX qw/strftime/;
-use Gruntmaster::Page::Common qw/header footer/;
+use Gruntmaster::Page::Common qw/cook_templates reload_templates/;
 use Gruntmaster::Data qw/problem_name problem_level problems/;
 
-my %templates = (
+my %orig_templates = (
   en => <<'HTML',
 <tmpl_if levels>
 <h2>Beginner</h2>
@@ -47,10 +45,10 @@ my %templates = (
 HTML
 );
 
-$templates{$_}  = header($_, TITLE) . $templates{$_} for keys %templates;
-$templates{$_} .= footer $_ for keys %templates;
+my %templates = cook_templates %orig_templates, pb => 'Problems';
 
 sub generate{
+       %templates = cook_templates %orig_templates, pb => 'Problems' if reload_templates;
        $_[0] =~ m,^(?:ct/([^/]+)/)?pb/index.html$,;
        local $Gruntmaster::Data::contest = $1;
 
This page took 0.024958 seconds and 4 git commands to generate.