From: http://jmtd.livejournal.com/ Date: Mon, 15 Nov 2010 14:28:05 +0000 (+0000) Subject: guard templates with the if directive where necessary X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/commitdiff_plain/da9e1ea667f82d5fca9168dbed19be08040570ff guard templates with the if directive where necessary --- diff --git a/doc/ikiwiki/directive/template.mdwn b/doc/ikiwiki/directive/template.mdwn index 9e3ae54df..df391f99e 100644 --- a/doc/ikiwiki/directive/template.mdwn +++ b/doc/ikiwiki/directive/template.mdwn @@ -60,22 +60,30 @@ few things: `text`. * To use one block of text if a variable is set and a second if it's not, use `textother text` +* Each template file included in the wiki's source will also generate a regular + wiki page. In many cases you might want to prevent some of your template + being interpreted for the regular page. Use the [[if]] directive with the + `included()` test to guard the template code. Here's a sample template: - - Name: \[[]]
- Age:
- - Favorite color:
- - No favorite color.
-
- -
- -
-
+ \[[!if test="included()" then=""" + + Name: \[[]]
+ Age:
+ + Favorite color:
+ + No favorite color.
+
+ +
+ +
+
+ """ else=""" + This is a template page. + """]] 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