1 A simple plugin to allow per-page customization of a template by passing paramaters to HTML::Template. For those times when a whole pagetemplate is too much work. --Ethan
4 package IkiWiki::Plugin::tmplvars;
13 hook(type => "preprocess", id => "tmplvars", call => \&preprocess);
14 hook(type => "pagetemplate", id => "tmplvars", call => \&pagetemplate);
17 sub preprocess (@) { #{{{
20 if ($params{page} eq $params{destpage}) {
21 my $page = $params{page};
22 if (undef $tmplvars{$page}){
23 $tmplvars{$page} = {};
25 # XXX: The only way to get at just the user-specified params is
26 # to try to remove all the Ikiwiki-supplied ones.
28 delete $params{destpage};
29 delete $params{preview};
30 foreach my $arg (keys %params){
31 $tmplvars{$page}->{$arg} = $params{$arg};
37 sub pagetemplate (@) { #{{{
39 my $template = $params{template};
41 if (exists $tmplvars{$params{page}}) {
42 foreach my $arg (keys %{$tmplvars{$params{page}}}){
43 $template->param($arg => $tmplvars{$params{page}}->{$arg});