Archive for the ‘Freemarker’ Category

Freemarker: Html Table odd or even rows with Freemarker

Thursday, April 9th, 2009

When iterating on a list, you can use the “_index” value to css-mark the odd or even rows on a table.

<table>
[#list docs as doc]
[#assign trCss = (doc_index % 2 == 0)?string("","odd")]
<tr class=”${trCss}”>
<td>some data</td>
</tr>
[/#list]
</table>

Freemarker: hasNext

Saturday, October 11th, 2008
[#assign seq = ["winter", "spring", "summer", "autumn"]]
[#list seq as x]
${x_index + 1}. ${x}[#if x_has_next],[/#if]
[/#list]

See Freemarker doc for more.