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.

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

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]

See Freemarker doc for more.