Content

Incremental variables

Incremental variables are variables that increment by one each time they are referenced. Consider the following example content file:

 I'm an incremental variable: %a%
 Here I am again: %a%
 And finally: %a%

The generated page will be:

 I'm a incremental variable: 1
 Here I am again: 2
 And finally: 3

This can be used when creating footnotes or for numbering headings.

Using incremental variables for footnotes

Standard notation for footnotes reference in text is [[X]] (where X is a number) and the actual footnote is fnX Text. The clue is that the footnote number (X) must match the reference in the text and the actual footnote.

To ease maintenance the X can be replaced by two incremental variables. E.g. [[%a%]] and fn%b% Text.

Using incremental variables for header numbering

For numbering section headers, try the following:

 h2 %a% The first title
 Some text

 h2 %a% The second title
 Some more text

It will produce:

 <h2>1 The first title</h2>
 <p>Some text</p>

 <h2>2 The second title</h2>
 <p>Some more text</p>
Last changed 2009-10-17 21:09