]> sipb.mit.edu Git - ikiwiki.git/blob - doc/plugins/conditional.mdwn
web commit by JoshTriplett: Link URL more simply.
[ikiwiki.git] / doc / plugins / conditional.mdwn
1 [[template id=plugin name=conditional core=1 author="[[Joey]]"]]
2 [[tag type/format]]
3
4 With this plugin, you can make text be conditionally displayed on a page.
5 For example:
6
7         \[[if test="enabled(smiley)"
8               then="The smiley plugin is enabled :-)"
9               else="No smiley plugin here.."]]
10
11 If the specified `test` succeeds, the `then` text will be displayed,
12 otherwise the `else` text will be displayed. The `else` part is optional.
13
14 The `then` and `else` values can include any markup that would be allowed
15 in the wiki page outside the template. Triple-quoting the values even allows
16 quotes to be included.
17
18 The `test` is a [[PageSpec]]; if it matches any page in the wiki then it
19 succeeds. So you can do things like testing for the existence of a page or
20 pages, testing to see if any pages were created in a given month, and so
21 on. The regular [[PageSpec]] syntax is expanded with the following
22 additional tests:
23
24 * enabled(plugin)
25
26   Tests whether the specified plugin is enabled.
27
28 * sourcepage(glob)
29
30   Tests whether the glob matches the name of the page that contains the
31   conditional.
32
33 * destpage(glob)
34
35   Tests whether the glob matches the name of the page that is being built.
36   That might be different than the name of the page that contains the
37   conditional, if it's being inlined into another page.
38
39 * included()
40
41   Tests whether the page is being included onto another page.