+sub patch_templates {
+ my $root = $ENV{GRUNTMASTER_TEMPLATE_ROOT} or return;
+ my ($templates, $name) = @_;
+ my %out = %$templates;
+ for (<$root/$name*>) {
+ m/\.(.+)$/;
+ $out{$1} = read_file $_
+ }
+
+ %out
+}
+
+my %header_templates = patch_templates \%orig_header_templates, 'header';
+my %footer_templates = patch_templates \%orig_footer_templates, 'footer';
+
+sub reload_templates () { $ENV{GRUNTMASTER_RELOAD_TEMPLATES} }
+