From: Joey Hess Date: Fri, 23 Apr 2010 19:11:25 +0000 (-0400) Subject: use template() rather than rolling it by hand X-Git-Tag: 3.20100427~45 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d1cc7e81c84e57c32b6560f82065caf6535c0692;p=ikiwiki.git use template() rather than rolling it by hand --- diff --git a/IkiWiki/Plugin/edittemplate.pm b/IkiWiki/Plugin/edittemplate.pm index 5f0551d92..d65072010 100644 --- a/IkiWiki/Plugin/edittemplate.pm +++ b/IkiWiki/Plugin/edittemplate.pm @@ -114,28 +114,18 @@ sub filltemplate ($$) { my $template_page=shift; my $page=shift; - my $template_file=$pagesources{$template_page}; - if (! defined $template_file) { - return; - } - my $template; eval { - $template=HTML::Template->new( - filter => sub { - my $text_ref = shift; - $$text_ref=&Encode::decode_utf8($$text_ref); - chomp $$text_ref; - }, - filename => srcfile($template_file), - die_on_bad_params => 0, - no_includes => 1, - ); + # force page name absolute so it doesn't look in templates/ + $template=template("/".$template_page); }; if ($@) { # Indicate that the earlier preprocessor directive set # up a template that doesn't work. - return "[[!pagetemplate ".gettext("failed to process")." $@]]"; + return "[[!pagetemplate ".gettext("failed to process template:")." $@]]"; + } + if (! defined $template) { + return; } $template->param(name => $page);