X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/40959ce76d159cefaf0431ad2cc61ad35a9f99b1..805e16ec65c338323333244fb67c59e1d69ba96f:/IkiWiki/Plugin/pagetemplate.pm?ds=sidebyside diff --git a/IkiWiki/Plugin/pagetemplate.pm b/IkiWiki/Plugin/pagetemplate.pm index b5ebf623d..60db8b327 100644 --- a/IkiWiki/Plugin/pagetemplate.pm +++ b/IkiWiki/Plugin/pagetemplate.pm @@ -7,27 +7,37 @@ use IkiWiki 2.00; my %templates; -sub import { #{{{ +sub import { + hook(type => "getsetup", id => "pagetemplate", call => \&getsetup); hook(type => "preprocess", id => "pagetemplate", call => \&preprocess); hook(type => "templatefile", id => "pagetemplate", call => \&templatefile); -} # }}} +} -sub preprocess (@) { #{{{ +sub getsetup () { + return + plugin => { + safe => 1, + rebuild => undef, + }, +} + +sub preprocess (@) { my %params=@_; if (! exists $params{template} || $params{template} !~ /^[-A-Za-z0-9._+]+$/ || ! defined IkiWiki::template_file($params{template})) { - return "[[pagetemplate ".gettext("bad or missing template")."]]"; + error gettext("bad or missing template") } if ($params{page} eq $params{destpage}) { $templates{$params{page}}=$params{template}; } -} # }}} + return ""; +} -sub templatefile (@) { #{{{ +sub templatefile (@) { my %params=@_; if (exists $templates{$params{page}}) { @@ -35,6 +45,6 @@ sub templatefile (@) { #{{{ } return undef; -} # }}} +} 1