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);
37 filename => srcfile($template_file),
38 die_on_bad_params => 0,
43 foreach my $param (keys %params) {
44 $template->param($param => $params{$param});
47 return IkiWiki::preprocess($params{page}, $params{destpage},