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

Jiwon Seo jiwon at stanford.edu
Mon Nov 28 11:03:41 PST 2011


Thanks.

Actually I have one more question.
What I really want to do is to concatenate <i0> with a constant string
and pass it as an argument
as following:

<sorted:{s|<if(s)><insert("pos", "prefix"+<i0>)><endif>}; separator=";\n">

but it seems like it doesn't work with or without <>

-Jiwon


On Mon, Nov 28, 2011 at 9:02 AM, Terence Parr <parrt at cs.usfca.edu> wrote:
> 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