]> sipb.mit.edu Git - ikiwiki.git/blobdiff - doc/templates.mdwn
Fix get_ctime implementation in Bazaar plugin, add get_mtime implementation.
[ikiwiki.git] / doc / templates.mdwn
index 24da881c7a71e4af0741aba5065a5d833735144f..07531ae98811442280467ee61e47822b6c3354c0 100644 (file)
@@ -1,3 +1,4 @@
+[[!meta robots="noindex, follow"]]
 [[!if test="enabled(template)"
 then="This wiki has templates **enabled**."
 else="This wiki has templates **disabled**."
@@ -8,8 +9,6 @@ wiki.
 
 [[!if test="enabled(template) and enabled(inline)" then="""
 
-## Available templates
-
 These templates are available for inclusion onto other pages in this
 wiki:
 
@@ -39,15 +38,25 @@ large chunks of marked up text to be embedded into a template:
 
 ## Creating a template
 
-To create a template, simply add a template directive to a page, and page will
-provide a link that can be used to create the template. The template is a
-regular wiki page, located in the `templates/` directory.
+To create a template, simply add a template directive to a page, and the 
+page will provide a link that can be used to create the template. The template
+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
 few things:
 
+* Each parameter you pass to the template directive will generate a 
+  template variable. There are also some pre-defined variables like PAGE
+  and BASENAME.
 * To insert the value of a variable, use `<TMPL_VAR variable>`. Wiki markup
   in the value will first be converted to html.
 * To insert the raw value of a variable, with wiki markup not yet converted
@@ -60,7 +69,7 @@ few things:
 Here's a sample template:
 
         <span class="infobox">
-        Name: [[<TMPL_VAR raw_name>]]<br />
+        Name: \[[<TMPL_VAR raw_name>]]<br />
         Age: <TMPL_VAR age><br />
         <TMPL_IF NAME="color">
         Favorite color: <TMPL_VAR color><br />
@@ -78,6 +87,7 @@ that contains it, so you can include WikiLinks and all other forms of wiki
 markup in the template. Note though that such WikiLinks will not show up as
 backlinks to the page that uses the template.
 
-Note the use of "raw_name" inside the [[WikiLink]] generator. This ensures
-that if the name contains something that might be mistaken for wiki markup,
-it's not converted to html before being processed as a [[WikiLink]].
+Note the use of "raw_name" inside the [[ikiwiki/WikiLink]] generator. This
+ensures that if the name contains something that might be mistaken for wiki
+markup, it's not converted to html before being processed as a
+[[ikiwiki/WikiLink]].