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
6 package IkiWiki::Plugin::tmplvars;
15 hook(type => "preprocess", id => "tmplvars", call => \&preprocess);
16 hook(type => "pagetemplate", id => "tmplvars", call => \&pagetemplate);
19 sub preprocess (@) { #{{{
22 if ($params{page} eq $params{destpage}) {
23 my $page = $params{page};
24 if (undef $tmplvars{$page}){
25 $tmplvars{$page} = {};
27 # XXX: The only way to get at just the user-specified params is
28 # to try to remove all the Ikiwiki-supplied ones.
30 delete $params{destpage};
31 delete $params{preview};
32 foreach my $arg (keys %params){
33 $tmplvars{$page}->{$arg} = $params{$arg};
39 sub pagetemplate (@) { #{{{
41 my $template = $params{template};
43 if (exists $tmplvars{$params{page}}) {
44 foreach my $arg (keys %{$tmplvars{$params{page}}}){
45 $template->param($arg => $tmplvars{$params{page}}->{$arg});