2 # Structured template plugin.
3 package IkiWiki::Plugin::template;
12 hook(type => "preprocess", id => "template", call => \&preprocess);
15 sub preprocess (@) { #{{{
18 if (! exists $params{id}) {
19 return "[[template missing id parameter]]"
22 my $template_page="templates/$params{id}";
23 add_depends($params{page}, $template_page);
25 my $template_file=$pagesources{$template_page};
27 htmllink($params{page}, $params{destpage}, $template_page).
29 unless defined $template_file;
31 my $template=HTML::Template->new(
34 $$text_ref=&Encode::decode_utf8($$text_ref);
36 filename => srcfile($template_file),
37 die_on_bad_params => 0,
42 foreach my $param (keys %params) {
43 $template->param($param => $params{$param});
46 return IkiWiki::preprocess($params{page}, $params{destpage},