sub _fill_in { my ($template, %params) = @_; $params{include} = sub { _fill_in(shift, %params, @_); return ''; }; my $template = Text::Template->new( SOURCE => catfile($templates_path, "$template.tmpl")); $template->fill_in(HASH => \%params, OUTPUT => \*STDOUT); } #### {include('_header', title => 'Page title')}

Some text...

{include('_footer')}