From 6d78fc24dc7d6e7cdc9edfec73fa6f269f91b5eb Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Wed, 15 Jan 2014 19:35:55 +0200 Subject: [PATCH] Add support for template patches --- lib/Gruntmaster/Page/Common.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/Gruntmaster/Page/Common.pm b/lib/Gruntmaster/Page/Common.pm index 258f7e7..65cf53c 100644 --- a/lib/Gruntmaster/Page/Common.pm +++ b/lib/Gruntmaster/Page/Common.pm @@ -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; -- 2.39.2