]> iEval git - gruntmaster-page.git/blobdiff - lib/Gruntmaster/Page/Learn.pm
Centralize template cooking and introduce reloadable templates
[gruntmaster-page.git] / lib / Gruntmaster / Page / Learn.pm
index 1ba2e4ed165c7de4f1e9d511c6a1cfdcf9ac69c6..171a184ae5eeb6e211784239d3833fc5f88eb72d 100644 (file)
@@ -7,22 +7,20 @@ use parent qw/Exporter/;
 our @EXPORT_OK = qw/generate/;
 our $VERSION = '0.001';
 
-use constant TITLE => 'Learn';
-
 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',
 Install interactive-perl-tutorial from your nearest CPAN mirror. Run <code>cpan App::InteractivePerlTutorial</code>.
 <p>You can also get the source from <a href="http://git.ieval.ro/?p=app-interactiveperltutorial.git">git.ieval.ro</a>
 HTML
 );
 
-$templates{$_}  = header($_, TITLE) . $templates{$_} for keys %templates;
-$templates{$_} .= footer $_ for keys %templates;
+my %templates = cook_templates %orig_templates, learn => 'Learn';
 
 sub generate{
+  %templates = cook_templates %orig_templates, learn => 'Learn' if reload_templates;
   HTML::Template::Compiled->new(scalarref => \$templates{$_[1]})->output;
 }
 
This page took 0.019181 seconds and 4 git commands to generate.