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