summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/workflows/workflows-setups.tex
blob: e9d120f7b91a92f86be254ffa9c67f70e298aa79 (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
64
65
66
67
68
69
70
71
72
% language=uk

\environment workflows-style

\startcomponent workflows-setups

\startchapter[title={Setups}]

Setups are a powerful way to organize styles. They are basically macros but live
in their own namespace. One advantage is that spaces in a setup are ignored so
you can code without bothering about spurious spaces. Here is a trick that you
can use when one style contains directives for multiple products:

\startbuffer
\startsetups tex:whatever
    \fastsetup{tex:whatever:\documentvariable{stylevariant}}
\stopsetups

\startsetups tex:whatever:foo
    FOO
\stopsetups

\startsetups tex:whatever:bar
    BAR
\stopsetups
\stopbuffer

\typebuffer \getbuffer

Here we define a main setup \type {tex:whatever} that gets expanded in one of two
variants, controlled by a document variable.

\startbuffer
\setups{tex:whatever}

\setupdocument
  [stylevariant=foo]

\setups{tex:whatever}

\setupdocument
  [stylevariant=bar]

\setups{tex:whatever}
\stopbuffer

\typebuffer

These lines result in:

\getbuffer

In a similar fashion you can define \XML\ setups that are used to render
elements:

\starttyping
\startxmlsetups xml:whatever
    \xmlsetup{#1}{xml:whatever:\documentvariable{stylevariant}}
\stopxmlsetups

\startxmlsetups xml:whatever:foo
    FOO: \xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:whatever:bar
    BAR: \xmlflush{#1}
\stopxmlsetups
\stoptyping

\stopchapter

\stopcomponent