[stringtemplate-interest] nested attributes

Terence Parr parrt at cs.usfca.edu
Mon Mar 20 16:01:48 PST 2006


On Mar 20, 2006, at 3:57 PM, David Moshal wrote:

> Hi, I have a data structure as follows:
>
> public class Section
> {
>      Vector <Group> groups;
> }
>
> public class Group
> {
>      String name;
> }
>
> I'd like my template to be able to show sections and groups:
>
> setAttribute ("sections", sections); // sections is a collection of  
> sections
>
> and in the template:
>
>
> $sections:
>
>      $it.groups:
>
>           $it.name$
>      $
> $
>
> Any ideas??
>
Just as you have it :)

$sections:{s |
	$s.groups:{g | Group name is $g.name$}$
}$

Ter


More information about the stringtemplate-interest mailing list