thoughts, responses
[ikiwiki] / doc / todo / conditional_text_based_on_ikiwiki_features.mdwn
1 I'd like to see some way to conditionally include wiki text based on
2 whether the wiki enables or disables certain features.  For example,
3 [[helponformatting]], could use `\[[if (enabled smiley) """Also, because
4 this wiki has the smiley plugin enabled, you can insert \[[smileys]] and
5 some other useful symbols."""]]`, and a standard template for [[plugins]]
6 pages could check for the given plugin name to print "enabled" or
7 "disabled".
8
9 Some potentially useful conditionals:
10
11 * `enabled pluginname`
12 * `disabled pluginname`
13 * `any pagespec`: true if any of the pages in the [[PageSpec]] exist
14 * `all pagespec`: true if all of the pages in the [[PageSpec]] exist
15 * `no pagespec` or `none pagespec`: true if none of the pages in the [[PageSpec]] exist
16 * `thispage pagespec`: true if pagespec includes the page getting rendered (possibly one including the page with this content on it).
17 * `sourcepage pagespec`: true if pagespec includes the page corresponding to the file actually containing this content, rather than a page including it.
18 * `included`: true if included on another page, via [[plugins/inline]], [[plugins/sidebar]], [[plugins/contrib/navbar]], etc.
19
20 You may or may not want to include boolean operations (`and`, `or`, and
21 `not`); if you do, you could replace `disabled` with `not enabled`, and `no
22 pagespec` or `none pagespec` with `not any pagespec` (but you may want to
23 keep the aliases for simplicity anyway).  You also may or may not want to
24 include an `else` clause; if so, you could label the text used if true as
25 `then`.
26
27 Syntax could vary greatly here, both for the [[PreprocessorDirective]] and
28 for the condition itself.
29
30 > I think this is a good thing to consider, although conditionals tend to
31 > make everything a lot more complicated, so I also want to KISS, and not
32 > use too many of them.
33
34 > I'd probably implement this using the same method as pagespecs, so 'and',
35 > 'or', '!', and paren groupings work.
36
37 > It could be thought of as simply testing to see if a pagespec matches
38 > anything, using a slightly expanded syntax for the pagespec, which would
39 > also allow testing for things like link(somepage),
40 > created_before(somepage), etc.
41
42 > That also gives us your "any pagespec" for free: "page or page or page".
43 > And for "all pagespec", you can do "page and page and page". 
44
45 > For plugins testing, maybe just use "enabled(name)"?
46
47 > I'm not sure what the use cases are for thispage, sourcepage, and
48 > included. I don't know if the included test is even doable. I'd be
49 > inclined to not bother with these three unless there are use cases I'm
50 > not seeing.
51
52 > As to the syntax, to fit it into standard preprocessor syntax, it would
53 > need to look something like this:
54 >
55 >       \[[if test="enabled(smiley)" """foo"""]]
56
57 > --[[Joey]]