12.3 Including user variables in DITA2Go macros

Suppose you want to produce a list of titles in your document. If you want all titles, you could assign property Var to title (see §11.2 Specifying properties of element types). If you want only chapter titles, you could assign a user variable name to an element path that begins with title:

[VariableMaps]
title/$topic/1 = title

You could create a macro that iterates through the resulting <$$title[n]> multiple-instance user variable:

[WriteTitles]
<$$title><$_repeat ($$title[])><br>
<$$title[$$_wcount]><$endrepeat>\

and invoke the macro with code assigned to another macro, or to a configuration setting:

<p class="titles"><$WriteTitles></p>

to produce a list of titles:

<p class="titles">Test Suite Design<br>
Purpose<br>
Suite Components<br>
Expected Results<br>
Test Suite Operation<br>
Test Suite Coverage<br>
Contributors<br>
. . .

See §37.1 Defining and invoking macros.

Previous Topic:  12.2 Assigning variable names to element paths

Next Topic:  12.4 Deploying user variables in template macros

Parent Topic:  12. Creating and deploying user variables

Sibling Topics:

12.1 Understanding how DITA2Go user variables work

12.2 Assigning variable names to element paths

12.4 Deploying user variables in template macros

Table of ContentsIndex