Add support for template patches
authorMarius Gavrilescu <marius@ieval.ro>
Wed, 15 Jan 2014 17:35:55 +0000 (19:35 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Wed, 15 Jan 2014 17:35:55 +0000 (19:35 +0200)
lib/Gruntmaster/Page/Common.pm

index 258f7e753bcf9537d5825dd8a2704fc852275995..65cf53c334777f90fea6f96659d80fa75621a1e8 100644 (file)
@@ -4,7 +4,9 @@ use 5.014000;
 use strict;
 use warnings;
 use parent qw/Exporter/;
-our @EXPORT_OK = qw/header footer/;
+our @EXPORT_OK = qw/header footer patch_templates/;
+
+use File::Slurp qw/read_file/;
 
 my %header_templates = (
   en => <<'HTML',
@@ -35,6 +37,18 @@ Dilmom: Well, it's a stripped-down version of the Gruntmaster 9000, of course. B
 HTML
 );
 
+sub patch_templates (\%$){
+       my $root = $ENV{GRUNTMASTER_TEMPLATE_ROOT} or return;
+       my ($templates, $name) = @_;
+       for (<$root/$name*>) {
+               m/\.(.+)$/;
+               $templates->{$1} = read_file $_
+       }
+}
+
+patch_templates %header_templates, 'header';
+patch_templates %footer_templates, 'footer';
+
 sub header{
   my ($language, $title) = @_;
   $header_templates{$language} =~ s/TITLE_GOES_HERE/$title/ger;
This page took 0.011082 seconds and 4 git commands to generate.