2 # Structured template plugin.
3 package IkiWiki::Plugin::template;
12 IkiWiki::hook(type => "preprocess", id => "template",
13 call => \&preprocess);
16 sub preprocess (@) { #{{{
19 if (! exists $params{id}) {
20 return "[[template missing id parameter]]"
23 my $template_page="templates/$params{id}";
24 IkiWiki::add_depends($params{page}, $template_page);
26 my $template_file=$IkiWiki::pagesources{$template_page};
28 IkiWiki::htmllink($params{page}, $params{destpage}, $template_page).
30 unless defined $template_file;
32 my $template=HTML::Template->new(
35 $$text_ref=&Encode::decode_utf8($$text_ref);
37 filename => IkiWiki::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},