[stringtemplate-interest] [RE:] Re: i0 with alternating templates
Daniel Brenner
daniel.brenner at cas.de
Wed Aug 24 07:47:45 PDT 2011
Interessting: I would have expected that i and i0 are available in each loop and not only in anonymous templates. What is the reason for this? (for me this makes no sence... so far)
Anyway: thanks a lot!
Cheers,
- Daniel
Ursprüngliche Nachricht
Absender: Udo Borkowski ub at abego-software.de
Gesendet am: 23.08.2011 18:45:34
Betreff: [RE:] Re: [stringtemplate-interest] i0 with alternating templates
Empfänger: Daniel Brenner daniel.brenner at cas.de
CC: stringtemplate-interest at antlr.org
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/20110824/6cc646fe/attachment.html
More information about the stringtemplate-interest
mailing list