summaryrefslogtreecommitdiff
path: root/ikiwiki/directive/if.mdwn
blob: 6e7ce0519f3ceec09b41ab4fd5c9418f08dcc9b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
[[!if test="enabled(if)"
  then="In diesem Wiki ist die Direktive: if **aktiviert**."
 else="In diesem Wiki ist die Direktive: if **nicht aktiv**; falls dies gewünscht wird, den Admin benachrichtigen."]]

---
The `if` directive is supplied by the [[!iki plugins/conditional desc=conditional]] plugin.

With this directive, you can make text be conditionally displayed on a page.
For example:

	\[[!if test="enabled(smiley)"
	      then="The smiley plugin is enabled :-)"
	      else="No smiley plugin here.."]]

If the specified `test` succeeds, the `then` text will be displayed,
otherwise the `else` text will be displayed. The `else` part is optional.

The `then` and `else` values can include any markup that would be allowed
in the wiki page outside the template. Triple-quoting the values even allows
quotes to be included.

The `test` is a [[ikiwiki/PageSpec]]; if it matches any page in the wiki
then it succeeds. So you can do things like testing for the existence of a
page or pages, testing to see if any pages were created in a given month,
and so on.

If you want the [[ikiwiki/PageSpec]] to only match against the page that
contains the conditional, rather than matching against all pages in the
wiki, set the "all" parameter to "no".

In an `if` directive, the regular [[ikiwiki/PageSpec]] syntax is expanded
with the following additional tests:

* enabled(plugin)

  Tests whether the specified plugin is enabled.

* sourcepage(glob)

  Tests whether the glob matches the name of the page that contains the
  conditional.

* destpage(glob)

  Tests whether the glob matches the name of the page that is being built.
  That might be different than the name of the page that contains the
  conditional, if it's being inlined into another page.

* included()

  Tests whether the page is being included onto another page, for example
  via [[inline]] or [[map]].  Note that pages inserted into other pages
  via [[template]] are not matched here.

[[!meta robots="noindex, follow"]]