[stringtemplate-interest] Question on index with an offset in a sub-template
Terence Parr
parrt at cs.usfca.edu
Sun Feb 12 10:01:15 PST 2012
Hi Jiwon, I think here, to be general, you need to pass in a map or 2 lists: {"apple":9, "orange":30}
then
<attrs:{a| <a> is <attrs.(a)>th item}; separator=", ">.
if attrs is hash. this is for v4. in v3, iteration was on values not keys.
T
On Feb 11, 2012, at 7:52 PM, Jiwon Seo wrote:
> Hi,
>
> I have a question and/or a suggestion.
>
> I want to use an index with a specified offset in a subtemplate. I
> understand that currently you can use an index starting from 0 or 1
> like following:
>
> <attrs:{a| <a> is <i0>th item}; separator=", ">.
>
> which will give the following result if attrs is ["apple", "orange"]
>
> apple is 0th item, orange is 1th item.
>
> However, I have an offset for the index and want to use it something
> like following:
>
> <attrs:{a| <a> is <i.(offset)>th item}; separator=", ">.
>
> Where offset is an (integer) attribute.
>
> Is it possible to do this? If not, do you guys think it's a good idea
> to add this to StringTemplate?
>
> Thanks,
>
> -Jiwon
> _______________________________________________
> 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