[stringtemplate-interest] alternating row colows
Terence Parr
parrt at cs.usfca.edu
Thu Mar 1 17:50:24 PST 2007
how about using a template reference instead of an anonymous template
and then pass a different color:
$stuff:row(color="red"), row(color="green")$
I *think* that works. ;)
Ter
On Mar 1, 2007, at 4:30 PM, Nate wrote:
> 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
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list