Hm. Perhaps you're screwed there.
I mean, you could always write some Tcl code in <% ... %> to do what you need to do. Not very pretty, but it'd work.
Other than that, I don't have any good ideas. The templating system wasn't designed for generic data structures, and you're trying to squeeze something out of it that it wasn't designed for.
Anybody else?