]> iEval git - plack-app-gruntmaster.git/blobdiff - lib/Gruntmaster/Page/Index.pm
Centralize template cooking and introduce reloadable templates
[plack-app-gruntmaster.git] / lib / Gruntmaster / Page / Index.pm
index 4f20bace0494fe0ed79b21e148d4ab459a635a22..0214ea6b5c906de88d294e36270f0f131d05dc07 100644 (file)
@@ -7,20 +7,18 @@ use parent qw/Exporter/;
 our @EXPORT_OK = qw/generate/;
 our $VERSION = '0.001';
 
-use constant TITLE => 'Gruntmaster 6000';
-
 use HTML::Template::Compiled;
-use Gruntmaster::Page::Common qw/header footer/;
+use Gruntmaster::Page::Common qw/cook_templates reload_templates/;
 
-my %templates = (
+my %orig_templates = (
   en => <<'HTML',
 HTML
 );
 
-$templates{$_}  = header($_, TITLE) . $templates{$_} for keys %templates;
-$templates{$_} .= footer $_ for keys %templates;
+my %templates = cook_templates %orig_templates, index => 'Gruntmaster 6000';
 
 sub generate{
+  %templates = cook_templates %orig_templates, index => 'Gruntmaster 6000' if reload_templates;
   HTML::Template::Compiled->new(scalarref => \$templates{$_[1]})->output
 }
 
This page took 0.02355 seconds and 4 git commands to generate.