Set-type attributes can hold multi-value data, e.g. a set of tags. Some action operators can create sets, most notably the links() operator. Having created a set it can be useful to make it into an HTML list. This is easily done using the format() operator. For instance, if $MySet has values 'cow', 'dog' and 'eel':
format($MySet"<ul>\n","\t<li>","</li>\n","</ul>\n");
This gives:
<ul>
<li>cow</li>
<li>dog</li>
<li>eel</li>
</ul>
It is more convenient is to use the newer .format() command:
$MySet.format("<ul>\n","\t<li>","</li>\n","</ul>\n");
If the above were a list of notes' $Name values it is also possible to make the list items into links. This is possible using a two-step process. First the existing set's data is copied to a new set with each value enclosed by link export code:
$MySetB = $MySet.format("","^linkTo(",")^;","");
The format() operator is now called a second time to make an HTML list using a String attribute $FormattedList to hold the output:
$FormattedList = $MySetB.format("<ul>\n","\t<li>","</li>\n","</ul>\n");
On export, the ^linkTo()^ codes are expanded:
<ul>
<li><a href="Data/cow.html">cow</a></li>
<li><a href="Data/dog.html">dog</a></li>
<li><a href="Data/eel.html">eel</a></li>
</ul>
The $FormattedList attribute is simply a placeholder to store the fully formatted list ready for use in an export template, thus:
^value($FormattedList)^
.
The overall process can be done without needing a second set attribute if link() can be used to make the source set of values. Note the need to use the eval() operator to capture the link() output, on the fly, in set data form to pass into format():
$MySet = eval(links(Data).outbound.example.$Name).format("","^linkTo(",")^;","");
The second step remains the same:
$FormattedList = $MySet.format("<ul>\n","\t<li>","</li>\n","</ul>\n");