+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';
+