[stringtemplate-interest] Question on using index variable(<i> and <i0>) in invoked template

Terence Parr parrt at cs.usfca.edu
Mon Nov 28 09:02:39 PST 2011


hi. once inside <…> just use i0.  <insert("pos", i0)> :)
Ter
On Nov 28, 2011, at 2:08 AM, Jiwon Seo wrote:

> Hi,
> 
> I'm trying to invoke a template inside an anonymous template as following:
> 
> <sorted:{s|<if(s)><insert("pos", <i0>)><endif>}; separator=";\n">
> 
> So, for each value (s) in the attribute sorted, I want to add a string
> generated by the template insert only when s has the value true.
> When invoking the insert template, I need to pass the iteration count
> (index of s in the sorted).
> 
> The above template code produces an error message that <i0> is
> unexpected (more accurately, the "<" is unexpected).
> 
> How can I pass the iteration count to the invoked template?
> 
> Thanks!
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest



More information about the stringtemplate-interest mailing list