X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/ed30330ac23ca84235e09cfc2f0acd55d62e4a09..4c6d359b5fbe8f746965a2646a7bea03284b23cc:/IkiWiki/Plugin/template.pm diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm index 416762fe1..a2859b2a9 100644 --- a/IkiWiki/Plugin/template.pm +++ b/IkiWiki/Plugin/template.pm @@ -9,14 +9,23 @@ use HTML::Template; use Encode; sub import { #{{{ + hook(type => "getsetup", id => "template", call => \&getsetup); hook(type => "preprocess", id => "template", call => \&preprocess); } # }}} +sub getsetup () { #{{{ + return + plugin => { + safe => 1, + rebuild => undef, + }, +} #}}} + sub preprocess (@) { #{{{ my %params=@_; if (! exists $params{id}) { - return "[[template ".gettext("missing id parameter")."]]"; + error gettext("missing id parameter") } my $template_page="templates/$params{id}"; @@ -42,13 +51,15 @@ sub preprocess (@) { #{{{ ); }; if ($@) { - return "[[template ".gettext("failed to process:")." $@]]"; + error gettext("failed to process:")." $@" } + $params{basename}=IkiWiki::basename($params{page}); + foreach my $param (keys %params) { if ($template->query(name => $param)) { $template->param($param => - IkiWiki::htmlize($params{page}, + IkiWiki::htmlize($params{page}, $params{destpage}, pagetype($pagesources{$params{page}}), $params{$param})); }