in reply to Templating suggestions for code generation

As far as I understand the problem -
(from template toolkit)
[% FOREACH item IN items %] [% IF loop.first %] <ul> [% END %] <li>[% item %] ([% loop.count %] of [% loop.size %])</li> [% IF loop.last %] </ul> [% END %] [% END %]