[stringtemplate-interest] Variables in Template Parameters
Brain, Jim
JBrain at Aegonusa.com
Mon Nov 9 14:37:48 PST 2009
"TYPE.getName()" is the desired outcome.
I'm trying to refactor the following:
"$type$.get$name$()" into:
reader => '$type$.$getter$' and
property => '$reader(getter="get$name$()")$'
So I can pass different "getter" values into my template.
Jim
--
Jim Brain, AFP Architecture, 319-355-2070
-----Original Message-----
From: stringtemplate-interest-bounces at antlr.org [mailto:stringtemplate-interest-bounces at antlr.org] On Behalf Of Terence Parr
Sent: Monday, November 09, 2009 4:17 PM
To: StringTemplate Mailing List
Subject: Re: [stringtemplate-interest] Variables in Template Parameters
$type.(name)$ evaluates name to Name and type to TYPE then looks for
getName on TYPE or do you simply want TYPE.getName() as output?
T
On Nov 9, 2009, at 2:13 PM, Brain, Jim wrote:
> What would be the object in this case? The attributes I am trying to
> use are not in an object, they are attached directly to the template.
>
> Jim
>
>
> --
> Jim Brain, AFP Architecture, 319-355-2070
>
> -----Original Message-----
> From: stringtemplate-interest-bounces at antlr.org
> [mailto:stringtemplate-interest-bounces at antlr.org] On Behalf Of
> Terence Parr
> Sent: Monday, November 09, 2009 3:31 PM
> To: StringTemplate Mailing List
> Subject: Re: [stringtemplate-interest] Variables in Template
> Parameters
>
> Try $object.(attributeHoldingPropertyName)$
>
> Ter
> On Nov 9, 2009, at 1:14 PM, Brain, Jim wrote:
>
>> Is there a way to allow $getter$, which is passed "get$name$()" to
>> expand $name$ to "Name"?
>>
>> import org.antlr.stringtemplate.*;
>> public class STTest {
>> public static void main(String[] args) {
>> StringTemplateGroup stg = new StringTemplateGroup
>> ("Source");
>> stg.defineTemplate("reader","$type$.$getter$");
>> StringTemplateGroup stg2 = new StringTemplateGroup
>> ("Class");
>> stg2.setSuperGroup(stg);
>> StringTemplate st = stg2.defineTemplate("prop","$reader
>> (getter=\"get$name$()\")$");
>> st.setAttribute("name","Name");
>> st.setAttribute("type","TYPE");
>> System.out.println(st.toString());
>> }
>> }
>>
>> When I run this, I get:
>>
>> TYPE.get$name$()
>>
>> Which means the attributes are flowing through correctly, but the
>> substitution in the parameter is not occurring.
>>
>> --
>> Jim Brain, AFP Architecture, 319-355-2070
>> _______________________________________________
>> stringtemplate-interest mailing list
>> stringtemplate-interest at antlr.org
>> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>
>
_______________________________________________
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