[stringtemplate-interest] alternating row colows
Nate
misc at n4te.com
Thu Mar 1 16:30:53 PST 2007
I know ST supports alternating templates, eg...
$stuff:redRow(),greenRow()$
However, I don't see this as being useful for rendering an HTML table
with alternating row colors. Am I expected to do the following?
$stuff:{
<tr class="red">
<td>$it.firstName$</td>
<td>$it.lastName$</td>
<td>$it.address$</td>
</tr>
},{
<tr class="green">
<td>$it.firstName$</td>
<td>$it.lastName$</td>
<td>$it.address$</td>
</tr>
}$
I don't want to duplicate my template just to change the row color. I
don't want to put my template in another file so it can be reused. I
just want to know if the current row is even or odd. This is purely
presentation logic, so it should be easy. Is there an easier way to
accomplish this in ST?
In Smarty it is done with something like this...
<tr class="{cycle values="green,red"}">
<td>$it.firstName$</td>
<td>$it.lastName$</td>
<td>$it.address$</td>
</tr>
-Nate
More information about the stringtemplate-interest
mailing list