[stringtemplate-interest] AttributeProvider Proof of concept code

Collin Fagan collin.fagan at gmail.com
Thu Sep 15 06:04:14 PDT 2011


Hi Everyone,

I've checked in some code into the strum trunk that implements my
"AttributeProvider" idea.

I had to override some methods in Interpreter. Here is a link to the code
for that.

https://project-strum.svn.sourceforge.net/svnroot/project-strum/trunk/strum-project/strum/src/main/java/com/collinfagan/strum/interpreters/DynamicAttributeInterpreter.java

After that it was just a matter of extending some classes to allow one to
set an attribute provider. Extended versions of ST and all the standard
STGroup implementations are here:

https://project-strum.svn.sourceforge.net/svnroot/project-strum/trunk/strum-project/strum/src/main/java/com/collinfagan/strum/template/


In the strum-spring project I have a test that shows how one might use this
to pull beans out of a spring context.

https://project-strum.svn.sourceforge.net/svnroot/project-strum/trunk/strum-project/strum-spring/src/test/java/com/collinfagan/strum/spring/

Now that this is done I'm thinking of building some some of STGroup that can
load "Raw Templates".

So instead of this:

main() ::= <<

First Name: <dataBean.firstName>
Last Name: <dataBean.lastName>

System Properties:
 java.runtime.name = <systemProperties.("java.runtime.name")>
 java.version = <systemProperties.("java.version")>

>>
All you need is this:

First Name: <dataBean.firstName>
Last Name: <dataBean.lastName>

System Properties:
 java.runtime.name = <systemProperties.("java.runtime.name")>
 java.version = <systemProperties.("java.version")>


And the file can end in whatever extension you like. What do people think?
Does this sound useful or am I crossing some line?

Thanks,
Collin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110915/b0a518e6/attachment.html 


More information about the stringtemplate-interest mailing list