The following re-write allows for multiple definitions of the same tag value in a template definition. This, in turn, allows us to use TMPL_LOOPS in our template directives; all-be-it in a rather limited way.

I would, personally, only use this feature for very basic loops and, although nested loops might be possible (with a little more tinkering) it think any attempt would be better served by Kathyrn Anderson's field et al. plugin.

It is (primarily) intended to allow insertion of organised CSS blocks (i.e. <div>) through template directives (since i can't seem to get HTML and Markup to mix the way I want).

Apologies for the re-write. I struggle reading perl code that I didn't write and (probably too often) re-format to reduce my head-aches. Anyway it didn't make sense to post the patch since everything's changed now.

sample template

# <TMPL_VAR HEADER0>

<table>
<TMPL_LOOP TEST0>
<tr>
    <td><TMPL_VAR DATA0></td>
    <td><TMPL_VAR DATA1></td>
</tr>
</TMPL_LOOP>
</table>

sample iki page

[[!meta  title="this is my loops page"]]

[[!template  id="loops"
header0="this is a table"
data0="cell0:0"
data1="cell0:1"
data0="cell1:0"
data1="cell1:1"
]]

files

IkiWiki/Plugin/template.pm