I was wondering if there was a nice way to render a Map to an HTML table within a .gsp page.
An example Map:
def map = ['Mammals':['Unicorn','Chimpanzee','Goat'],
'Reptiles':['Snake','Turtle']];
This would render to something like this:
<table>
<thead>
<tr>
<th>Mammals</th>
<th>Reptiles</th>
</tr>
</thead>
<tbody>
<tr>
<td>Unicorn</td>
<td>Snake</td>
</tr>
<tr>
<td>Chimpanzee</td>
<td>Turtle</td>
</tr>
<tr>
<td>Goat</td>
<td></td>
</tr>
</tbody>
</table>
Ideally I could then create my own custom tag, so I could do this:
<stackOverflow:tablizer map="${map}" />
Something like this – Probably a better way to do it, but this was what I came up with first.