my $template_page="templates/$params{id}";
add_depends($params{page}, $template_page);
- my $template_file=$pagesources{$template_page};
+ my $template_file;
+ if (exists $pagesources{$template_page}) {
+ $template_file=srcfile($pagesources{$template_page});
+ }
+ else {
+ $template_file=template_file("$params{id}.tmpl")
+ }
return sprintf(gettext("template %s not found"),
htmllink($params{page}, $params{destpage}, "/".$template_page))
unless defined $template_file;
$$text_ref=&Encode::decode_utf8($$text_ref);
chomp $$text_ref;
},
- filename => srcfile($template_file),
+ filename => $template_file,
die_on_bad_params => 0,
no_includes => 1,
blind_cache => 1,
* page.tmpl: Add Cache-Control must-revalidate to ensure that users
(especially of Firefox) see fresh page content.
* htmlscrubber: Allow colons in urls after '?'
+ * template: Search for templates in the templatedir, if they are not
+ found as pages in the wiki.
-- Joey Hess <joeyh@debian.org> Sat, 13 Mar 2010 14:48:10 -0500
is a regular wiki page, located in the `templates/` subdirectory inside
the source directory of the wiki.
+(Alternatively, templates can be stored in a directory outside the wiki,
+as files with the extension ".tmpl".
+By default, these are searched for in `/usr/share/ikiwiki/templates`;
+the `templatedir` setting can be used to make another directory be searched
+first.)
+
The template uses the syntax used by the [[!cpan HTML::Template]] perl
module, which allows for some fairly complex things to be done. Consult its
documentation for the full syntax, but all you really need to know are a
invoked via `\[[!template]]`, but don't have to "work" as wiki pages in their
own right. I think the normal [[plugins/template]] plugin could benefit from
this functionality.
+
+[[done]] --[[Joey]]
The aim is to keep almost all html out of ikiwiki and in the templates.
It ships with some basic templates which can be customised. These are
-located in /usr/share/ikiwiki/templates by default.
+located in `/usr/share/ikiwiki/templates` by default; the `templatedir`
+setting can be used to make another directory be searched first.
* `page.tmpl` - Used for displaying all regular wiki pages.
* `misc.tmpl` - Generic template used for any page that doesn't
different template than `page.tmpl`.
The [[plugins/template]] plugin also uses templates, though those
-[[templates]] are stored in the wiki and inserted into pages.
+[[templates]] are typically stored as pages in the wiki, and are inserted
+into pages.
The [[plugins/edittemplate]] plugin is used to make new pages default to
containing text from a template, which can be filled as out the page is