aboutsummaryrefslogtreecommitdiff
path: root/doc/ikiwiki
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2014-09-15 21:52:03 +0100
committerSimon McVittie <smcv@debian.org>2014-09-15 21:52:03 +0100
commit7f5c2cfa5a987d887f42d6db95f80f42ceb3b5ff (patch)
tree020a296316b69b723511ff5b327815f81dce3d46 /doc/ikiwiki
parent7660979f74f29560cd91220ade073d4ef2b9bcb0 (diff)
parentc04a26f3e70d654ccec5542daf8425e44cb5bac8 (diff)
downloadikiwiki-7f5c2cfa5a987d887f42d6db95f80f42ceb3b5ff.tar
ikiwiki-7f5c2cfa5a987d887f42d6db95f80f42ceb3b5ff.tar.gz
Merge branch 'ready/templatebody'
Diffstat (limited to 'doc/ikiwiki')
-rw-r--r--doc/ikiwiki/directive/edittemplate.mdwn12
-rw-r--r--doc/ikiwiki/directive/template.mdwn20
-rw-r--r--doc/ikiwiki/directive/templatebody.mdwn28
3 files changed, 55 insertions, 5 deletions
diff --git a/doc/ikiwiki/directive/edittemplate.mdwn b/doc/ikiwiki/directive/edittemplate.mdwn
index 6269f5dd8..70bd2ad25 100644
--- a/doc/ikiwiki/directive/edittemplate.mdwn
+++ b/doc/ikiwiki/directive/edittemplate.mdwn
@@ -18,13 +18,15 @@ the directive displaying a note about the template being registered, add
"silent=yes".
Often the template page contains a simple skeleton for a particular type of
-page. For the bug report pages in the above example, it might look
-something like:
+page, wrapped in a [[templatebody]] directive. For the bug report pages in
+the above example, it might look something like:
+ \[[!templatebody <<ENDBODY
Package:
Version:
Reproducible: y/n
Details:
+ ENDBODY]]
The template page can also contain [[!cpan HTML::Template]] directives,
like other ikiwiki [[templates]].
@@ -43,4 +45,10 @@ These variables might be set:
suitable for use in `\[[!meta date="<TMPL_VAR time>"]]`
(see [[meta]]) or `\[[!date "<TMPL_VAR time>"]]` (see [[date]]).
+Text outside the [[templatebody]] directive is not part of the template,
+and can be used to document it.
+
+If the template does not contain a [[templatebody]] directive, the entire
+source of the page is used for the template. This is deprecated.
+
[[!meta robots="noindex, follow"]]
diff --git a/doc/ikiwiki/directive/template.mdwn b/doc/ikiwiki/directive/template.mdwn
index 9e3ae54df..dd1ca3d52 100644
--- a/doc/ikiwiki/directive/template.mdwn
+++ b/doc/ikiwiki/directive/template.mdwn
@@ -31,16 +31,25 @@ large chunks of marked up text to be embedded into a template:
## Creating a template
-The template is a regular wiki page, located in the `templates/`
+The template is in a regular wiki page, located in the `templates/`
subdirectory inside the source directory of the wiki.
+The contents of the [[templatebody]] directive are used as the
+template. Anything outside that directive is not included in the template,
+and is usually used as documentation describing the template.
+
+If the template does not contain a [[templatebody]] directive, the entire
+source of the page is used for the template. This is deprecated, because
+it leads to the template markup being interpreted as ordinary
+page source when the page is built, as well as being used as the template.
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. When referring to templates outside the wiki source directory, the "id"
-parameter is not interpreted as a pagespec, and you must include the full filename
-of the template page, including the ".tmpl" extension. E.g.:
+parameter is not interpreted as a pagespec, you must include the full filename
+of the template page including the ".tmpl" extension,
+and the templatebody directive is not used. E.g.:
\[[!template id=blogpost.tmpl]]
@@ -63,6 +72,7 @@ few things:
Here's a sample template:
+ \[[!templatebody <<ENDBODY
<span class="infobox">
Name: \[[<TMPL_VAR raw_name>]]<br />
Age: <TMPL_VAR age><br />
@@ -76,6 +86,10 @@ Here's a sample template:
<TMPL_VAR notes>
</TMPL_IF>
</span>
+ ENDBODY]]
+
+ This template describes a person. Parameters: name, age,
+ color (favorite color, optional), notes (optional).
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
diff --git a/doc/ikiwiki/directive/templatebody.mdwn b/doc/ikiwiki/directive/templatebody.mdwn
new file mode 100644
index 000000000..dfadb2c2d
--- /dev/null
+++ b/doc/ikiwiki/directive/templatebody.mdwn
@@ -0,0 +1,28 @@
+The `templatebody` directive is supplied by the
+[[!iki plugins/templatebody desc=templatebody]] plugin.
+
+This directive allows wiki pages to be used as templates
+for the [[template]] or [[edittemplate]] directive, without having
+[[!cpan HTML::Template]] markup interpreted as wiki markup when that
+page is built.
+
+This directive does not produce any output in the wiki page that
+defines the template; the rest of that page can be used to to document
+how to use the template.
+
+The first, un-named parameter is the content of the template.
+Because templates often contain [[directives|ikiwiki/directive]], it's
+convenient to use the "here-document" syntax for it:
+
+ \[[!templatebody <<ENDBODY
+ [[!meta title="<TMPL_VAR name>"]]
+ [[!tag person]]
+ <dl>
+ <dt>Name:</dt><dd><TMPL_VAR name></dd>
+ <dt>Age:</dt><dd><TMPL_VAR age></dd>
+ </dl>
+
+ <TMPL_VAR description>
+ ENDBODY]]
+
+[[!meta robots="noindex, follow"]]