[stringtemplate-interest] nesting templates and getting the loop count of the outer loop
Roel Vanhout
rvanhout at riks.nl
Tue Oct 28 03:30:23 PDT 2008
Hello Terence,
My reasoning was like this: in initialize_dlgs (the 'outer' template),
the group_nr is set to i0 in the 'outer' context. That value is then
passed to the 'inner' template where 'i0' is the counter of the 'inner'
context.
So with data like this:
page_group 0
- page 0
- page 1
page_group 1
- page 0
- page 1
the results would be
0,0
0,1
1,0
1,1
because in the outer loop i0 is the number of the page_group, which is
passed as an argument to the inner loop (the 'initialize_dlg' template)
which then iterates over the pages, where the counter is the number of
the page in that page group.
I hope this is a bit understandable :)
It's very well possible that I'm misunderstanding what the loop counter
represents, although it does exectly what I expect for the 'inner' loop.
What I'm after is a way to find the number of the 'outer' loop inside
the 'inner' template.
Thanks for your time.
cheers,
roel
-----Original Message-----
From: Terence Parr [mailto:parrt at cs.usfca.edu]
Sent: Monday, October 27, 2008 19:27
To: Roel Vanhout
Cc: stringtemplate-interest at antlr.org
Subject: Re: [stringtemplate-interest] nesting templates and getting the
loop count of the outer loop
Hi Roel,
you are saying that group_nr = i0 in the template application; how
could the values be different?
Ter
On Oct 27, 2008, at 9:49 AM, Roel Vanhout wrote:
> Hi,
>
>
> I have situation similar to what was asked here:
> http://markmail.org/message/izumze7jxytlwsds#query
> :stringtemplate%20i0+page:1+mid:izumze7jxytlwsds+state:results but the
> results that the poster there gets are not the same for me. A
> regression maybe, or differences in the Java/C# version? Or more
> probable, me missing something.
>
> My problem is as follows: I have templates like this:
>
> initialize_dlg(group_nr) ::= <<
> m_DialogIndexes["<group_nr>,<i0>"] = newdlg<it.ViewName>; }
> >>
>
> initialize_dlgs() ::= <<
> <it.Pages:initialize_dlg(group_nr=i0);separator="\n">
> >>
>
> The expexted output is for <group_nr> (in initialize_dlg) to be 0 a
> couple of times, then 1 a couple of times etc. However, <group_nr> and
> <i0> are always the same in initialize_dlg, which leads me to believe
> that <group_nr> is somehow passed not as the value of i0 in
> initialize_dlgs() but as a string literal 'i0' which is then re-
> evaluated in initialize_dlg.
>
> I'm using StringTemplate 3.0.1 for C#. Thanks.
>
>
> cheers,
>
> roel
> _______________________________________________
> 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