[stringtemplate-interest] AttributeProvider Proof of concept code
Udo Borkowski
ub at abego-software.de
Thu Sep 15 11:38:39 PDT 2011
> Now that this is done I'm thinking of building some some of STGroup that can load "Raw Templates".
...
> And the file can end in whatever extension you like. What do people think? Does this sound useful or am I crossing some line?
I like the idea. If I recall correctly something similar was suggested recently. E.g. use the ".html" extension to edit an html template and still use a "classic" HTML editor.
Not sure how to handle the parameters for such templates.
In addition (or alternatively) I could imagine to extend ST4 with an "include" function. E.g.
main(firstName, lastName, age="unknown") ::= <<
<includeFile("sample.html")>
>>
The "sample.html" is a plain file (with any extension) and the parser will textually include it.
Udo
On 15.09.2011, at 15:04, Collin Fagan wrote:
> 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
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110915/348fe5a8/attachment-0001.html
More information about the stringtemplate-interest
mailing list