workflows-setups.tex /size: 1437 b    last modification: 2021-10-28 13:50
1% language=us runpath=texruns:manuals/workflows
2
3\environment workflows-style
4
5\startcomponent workflows-setups
6
7\startchapter[title={Setups}]
8
9Setups are a powerful way to organize styles. They are basically macros but live
10in their own namespace. One advantage is that spaces in a setup are ignored so
11you can code without bothering about spurious spaces. Here is a trick that you
12can use when one style contains directives for multiple products:
13
14\startbuffer
15\startsetups tex:whatever
16    \fastsetup{tex:whatever:\documentvariable{stylevariant}}
17\stopsetups
18
19\startsetups tex:whatever:foo
20    FOO
21\stopsetups
22
23\startsetups tex:whatever:bar
24    BAR
25\stopsetups
26\stopbuffer
27
28\typebuffer \getbuffer
29
30Here we define a main setup \type {tex:whatever} that gets expanded in one of two
31variants, controlled by a document variable.
32
33\startbuffer
34\setups{tex:whatever}
35
36\setupdocument
37  [stylevariant=foo]
38
39\setups{tex:whatever}
40
41\setupdocument
42  [stylevariant=bar]
43
44\setups{tex:whatever}
45\stopbuffer
46
47\typebuffer
48
49These lines result in:
50
51\getbuffer
52
53In a similar fashion you can define \XML\ setups that are used to render
54elements:
55
56\starttyping
57\startxmlsetups xml:whatever
58    \xmlsetup{#1}{xml:whatever:\documentvariable{stylevariant}}
59\stopxmlsetups
60
61\startxmlsetups xml:whatever:foo
62    FOO: \xmlflush{#1}
63\stopxmlsetups
64
65\startxmlsetups xml:whatever:bar
66    BAR: \xmlflush{#1}
67\stopxmlsetups
68\stoptyping
69
70\stopchapter
71
72\stopcomponent
73