blob: a85799b33138d866864f8b326a3270343ce9f54d (
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
56
57
58
59
60
61
62
63
|
<?xml version="1.0" encoding="utf-8"?>
<page xmlns="http://projectmallard.org/1.0/" xmlns:xsl="FIXME" style="xslt-template" id="mal.if.test">
<info>
<link type="guide" xref="mal-if" group="templates"/>
<link type="guide" xref="templates" group="mal"/>
<desc>Test if a condition is true.</desc>
<revision version="3.8" date="2012-11-05" status="final"/>
</info>
<title>mal.if.test</title>
<synopsis>
<title>Parameters</title>
<terms>
<item>
<title><code>$node</code></title>
<p>The element to check the condition for.</p>
</item>
<item>
<title><code>$test</code></title>
<p>The test expression.</p>
</item>
</terms>
</synopsis>
<p>This template evaluates the test expression <code>$test</code>, which is taken automatically
from the <sys>test</sys> or <sys>if:test</sys> attribute of <code>$node</code>. It splits the expression on
commas into subexpressions, then splits each subexpression on spaces into tokens.
A token is taken to be true if it's in one of the space-separated lists from
<code xref="mal.if.target">mal.if.target</code>, <code xref="mal.if.platform">mal.if.platform</code>, <code xref="mal.if.features">mal.if.features</code>, or <code xref="mal.if.custom">mal.if.custom</code>.
If the token starts with an exclamation point, the exclamation point is stripped
and the resulting truth value is negated.</p>
<p>A subexpression is true if all its tokens is true. The full test expression is
true if any subexpression is true. If the test expression is true, the literal
string <sys>'true'</sys> is returned. If the test expression is false, the empty
string is returned.</p>
<p>This template can handle "maybe" values: tokens that may or may not be true,
and whose truth values are deferred to post-transform time. A token is maybe
if it appears in the space-separated list <code xref="mal.if.maybe">mal.if.maybe</code>. If a subexpression
contains a maybe value and does not contain any false tokens, its truth value
is a special string constructed from the maybe tokens and starting with the
string <sys>if__</sys>. If any subexpressions are maybe and none of the subexpressions
are false, the return value is a space-separated list of the maybe strings.</p>
<p>Maybe tokens usually must be handled specifically by the importing stylesheet.
It's usually not sufficient to just add a token to <code xref="mal.if.maybe">mal.if.maybe</code>. This
template will handle any maybe token, but it does not handle the actual logic
of dynamically showing or hiding content based on those tokens.</p>
<list style="compact">
<title>Calls Parameters</title>
<item>
<p><link xref="mal.if.custom"/></p>
</item>
<item>
<p><link xref="mal.if.features"/></p>
</item>
<item>
<p><link xref="mal.if.maybe"/></p>
</item>
<item>
<p><link xref="mal.if.platform"/></p>
</item>
<item>
<p><link xref="mal.if.target"/></p>
</item>
</list>
</page>
|