[stringtemplate-interest] Clarification of objects-as-attributes

Terence Parr parrt at cs.usfca.edu
Fri Apr 3 17:40:48 PDT 2009


On Apr 1, 2009, at 9:50 AM, Sam Barnett-Cormack wrote:

> Hi all,
>
> I wanted to check this out before I went ahead and wrote it, and I  
> seem
> to be feeling a lack of clarity from the docs.
>
> I plan to pass in attributes that are objects, with their properties
> being accessed as sub-attributes (or whatever you'd call them). Like
> having an attribute "member" and passing in an instance of a  
> particular
> class with properties "name" and "docs" accessed as member.name and
> member.docs, docs also having members so getting potentially
> member.docs.head (although actually docs gets passed to another
> template, so it's just docs.head).
>
> I also plan to have member.type, which has a member parameters - and I
> want *parameters* to be multi-valued so I can iterate over it with
> <parameters:type();separator = " , ">
>
> Is this possible? Do I just make member.type.parameters a List<T> or
> array or something?

<expr:type()> works great. you can use a.b.c.d.e.f if you want where f  
is an array or list of any kind :)

> As a much quicker question, are the namespaces for templates and
> attributes distinct? That is, can I have an attribute type and a rule
> type()? It might sound confusing, and I may change it in any case, but
> my current design leads to <type:type()>.

Should work. different name space i think.
Ter


More information about the stringtemplate-interest mailing list