The <for> Tag
The <for> tag provides a quick way to iterate through a list of items.
It requires two attributes, name and values; the content item named
name is set to each space-separated value in the values string, and
the text inside the block is processed.
Supported Attributes
-
name
-
The name of the variable which will be set to each
value in the values list in turn (if you know your comp-sci
lingo, the iterator).
-
values
-
A space-separated list of values which is iterated
through.
-
namesubst
-
A Perl s/// substitution; each value in the values
list will be processed by this, if set.
Variable references to ${name} are processed immediately, so
you can use this variable inside another variable reference, like this:
${all_${name}_text} .
Example
Here's an example, taken from my own home site:
<!-- Create output for files in top dir -->
<for name="out" values="index contact work nonwork home">
<out file="${out}.html" name="${out}">
${jmason_template}
</out>
</for>
|