[stringtemplate-interest] i0 with alternating templates
Udo Borkowski
ub at abego-software.de
Tue Aug 23 09:45:31 PDT 2011
Wrapping the template calls into anonymous templates will give you access to i and i0.
In your example it may look like this:
$results:{$resultlistOddRow(i, someVar)$}, {$resultlistEvenRow(i, someVar)$}$
With the templates resultlistOddRow and resultlistEvenRow defined like this:
resultlistOddRow(nr,p) ::= "$nr$. $p$ (odd)$\n$"
resultlistEvenRow(nr,p) ::= "$nr$. $p$ (even)$\n$"
and
results: [A, B, C, D]
someVar: x
ST4 will render:
1. x (odd)
2. x (even)
3. x (odd)
4. x (even)
Udo
On 23.08.2011, at 14:43, Daniel Brenner wrote:
> Hi,
>
> I have a table with results that was build using alternating templates. The following lines is used for this:
>
> $results:resultlistOddRow(somevar), resultlistEvenRow(somevar)$
>
> How can I number the rows? In the templates resultlistOddRow and resultlistEvenRow I tried to access $i$ and $i0$ but stringtemplate keeps telling me "implicitly-defined attribute i not visible" and "implicitly-defined attribute i0 not visible".
>
> Any ideas?
>
> Cheers,
>
> - Daniel
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110823/1234b993/attachment.html
More information about the stringtemplate-interest
mailing list