]> sipb.mit.edu Git - ikiwiki.git/blobdiff - doc/templates.mdwn
wording
[ikiwiki.git] / doc / templates.mdwn
index 5120021a79e055717f5f31c011ccb2bb483bf6b4..c91037670133adac3e2e60b409a24c98d310de0d 100644 (file)
@@ -1,85 +1,87 @@
-[[!if test="enabled(template)"
-then="This wiki has templates **enabled**."
-else="This wiki has templates **disabled**."
-]]
+[[Ikiwiki]] uses many templates for many purposes. By editing its templates,
+you can fully customise this site.
 
-Templates are files that can be filled out and inserted into pages in the
-wiki.
+[[!if test="enabled(template)" then="""
+## The template directive
 
+The template directive allows wiki pages to be used as templates,
+filled out and inserted into other pages in the wiki.
+"""]]
 [[!if test="enabled(template) and enabled(inline)" then="""
-
-## Available templates
-
-These templates are available for inclusion onto other pages in this
-wiki:
-
 [[!inline pages="templates/* and !*/discussion" feeds=no archive=yes
-sort=title template=titlepage]]
+sort=title template=titlepage
+rootpage=templates postformtext="Add a new template named:"]]
 """]]
 
-## Using a template
-
-Using a template works like this:
-
-       \[[!template id=note text="""Here is the text to insert into my note."""]]
+[[!if test="enabled(edittemplate)" then="""
+## The edittemplate directive
 
-This fills out the [[note]] template, filling in the `text` field with
-the specified value, and inserts the result into the page.
+The edittemplate directive can be used to make new pages default to
+containing text from a template, which can be filled as out the page is
+edited.
+"""]]
 
-Generally, a value can include any markup that would be allowed in the wiki
-page outside the template. Triple-quoting the value even allows quotes to
-be included in it. Combined with multi-line quoted values, this allows for
-large chunks of marked up text to be embedded into a template:
+## Wiki templates
+
+These templates are used to build the wiki. The aim is to keep almost all
+html out of ikiwiki and in the templates.
+
+* `page.tmpl` - Used for displaying all regular wiki pages.
+* `misc.tmpl` - Generic template used for any page that doesn't
+  have a custom template.
+* `rsspage.tmpl` - Used for generating rss feeds for blogs.
+* `rssitem.tmpl` - Used for generating individual items on rss feeds.
+* `atompage.tmpl` - Used for generating atom feeds for blogs.
+* `atomitem.tmpl` - Used for generating individual items on atom feeds.
+* `inlinepage.tmpl` - Used for displaying a post in a blog.
+* `archivepage.tmpl` - Used for listing a page in a blog archive page.
+* `titlepage.tmpl` - Used for listing a page by title in a blog archive page.
+* `microblog.tmpl` - Used for showing a microblogging post inline.
+* `blogpost.tmpl` - Used for a form to add a post to a blog (and a rss/atom links)
+* `feedlink.tmpl` - Used to add rss/atom links if `blogpost.tmpl` is not used.
+* `aggregatepost.tmpl` - Used by the aggregate plugin to create
+  a page for a post.
+* `searchform.tmpl`, `googleform.tmpl` - Used by the search plugin 
+  and google plugin to add search forms to wiki pages.
+* `searchquery.tmpl` - This is a Omega template, used by the
+  search plugin.
+* `comment.tmpl` - Used by the comments plugin to display a comment.
+* `change.tmpl` - Used to create a page describing a change made to the wiki.
+* `recentchanges.tmpl` - Used for listing a change on the RecentChanges page.
+* `autoindex.tmpl` - Filled in by the autoindex plugin to make index pages.
+* `autotag.tmpl` - Filled in by the tag plugin to make tag pages.
+* `calendarmonth.tmpl`, `calendaryear.tmpl` - Used by ikiwiki-calendar to
+  make calendar archive pages.
+* `editpage.tmpl`, `editconflict.tmpl`, `editcreationconflict.tmpl`,
+  `editfailedsave.tmpl`, `editpagegone.tmpl`, `pocreatepage.tmpl`,
+  `editcomment.tmpl` `commentmoderation.tmpl`, `renamesummary.tmpl`,
+  `passwordmail.tmpl` - Parts of ikiwiki's user interface; do not
+  normally need to be customised.
+
+[[!if test="enabled(pagetemplate)" then="""
+## The pagetemplate directive
+
+The pagetemplate directive can allow individual pages to use a
+different template than `page.tmpl`.
+"""]]
 
-        \[[!template id=foo name="Sally" color="green" age=8 notes="""
-        * \[[Charley]]'s sister.
-        * "I want to be an astronaut when I grow up."
-        * Really 8 and a half.
-        """]]
+## Template locations
 
-## Creating a template
+Templates are located in `/usr/share/ikiwiki/templates` by default;
+the `templatedir` setting can be used to make another directory be
+searched first. Customized templates can also be placed inside the
+"templates/" directory in your wiki's source.
 
-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. (Not to be confused with the
-[[wikitemplates]] which are stored in a different location.)
+## Template syntax
 
-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:
+Ikiwiki uses the HTML::Template module as its template engine. This
+supports things like conditionals and loops in templates and is pretty easy
+to learn. All you really need to know are a few things:
 
-* 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
-  to html, use `<TMPL_VAR raw_variable>`.
+* To insert the value of a template variable, use `<TMPL_VAR variable>`.
 * To make a block of text conditional on a variable being set use
   `<TMPL_IF NAME="variable">text</TMPL_IF>`.
 * To use one block of text if a variable is set and a second if it's not,
   use `<TMPL_IF NAME="variable">text<TMPL_ELSE>other text</TMPL_IF>`
 
-Here's a sample template:
-
-        <span class="infobox">
-        Name: [[<TMPL_VAR raw_name>]]<br />
-        Age: <TMPL_VAR age><br />
-        <TMPL_IF NAME="color">
-        Favorite color: <TMPL_VAR color><br />
-        <TMPL_ELSE>
-        No favorite color.<br />
-        </TMPL_IF>
-        <TMPL_IF NAME="notes">
-        <hr />
-        <TMPL_VAR notes>
-        </TMPL_IF>
-        </span>
-
-The filled out template will be formatted the same as the rest of the page
-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]].
+[[!meta robots="noindex, follow"]]