1 [[template id=plugin name=template included=1 author="[[Joey]]"]]
4 With this plugin, you can set up templates, and cause them to be filled out
5 and inserted into pages in the wiki. Using a template works like this:
7 \[[template id=foo name="Charley" color="red" age=11]]
9 This fills out the template `templates/foo`, filling in the `color` and `age`
10 fields on it with the specified values, and inserts the result into the page.
12 (Note that if the template doesn't exist, the page will provide a link that
13 can be used to create it.)
15 A value can include any markup that would be allowed in the wiki page
16 outside the template. Triple-quoting the value even allows quotes to be
17 included in it. Combined with multi-line quoted values, this allows for
18 large chunks of marked up text to be embedded into a template:
20 \[[template id=foo name="Sally" color="green" age=8 notes="""
21 * \[[Charley]]'s sister.
22 * "I want to be an astronaut when I grow up."
23 * Really 8 and a half.
26 To create a template, make a page in the wiki named `template/foo`. Note
27 that this is a different location than the directory used for the
28 [[templates]] used to build the wiki itself, which is not inside the wiki.
30 The template uses the syntax used by the [[cpan HTML::Template]] perl
31 module, which allows for some fairly complex things to be done. Consult its
32 documentation for the full syntax, but all you really need to know are a
35 * To insert the value of a variable, use `<TMPL_VAR variable>`.
36 * To make a block of text conditional on a variable being set use
37 `<TMPL_IF NAME="variable">text</TMPL_IF>`.
38 * To use one block of text if a variable is set and a second if it's not,
39 use `<TMPL_IF NAME="variable">text<TMPL_ELSE>other text</TMPL_IF>`
41 Here's a sample template:
43 <span class="infobox">
44 Name: <TMPL_VAR name><br />
45 Age: <TMPL_VAR age><br />
46 <TMPL_IF NAME="color">
47 Favorite color: <TMPL_VAR color><br />
49 No favorite color.<br />
51 <TMPL_IF NAME="notes">