[stringtemplate-interest] AttributeProvider Proof of concept code
Collin Fagan
collin.fagan at gmail.com
Thu Sep 15 12:02:57 PDT 2011
*Not sure how to handle the parameters for such templates.*
Well see thats why you need an AttributeProvider. That way you don't have to
declare *any* parameters.
Collin
On Thu, Sep 15, 2011 at 1:37 PM, Udo Borkowski <Udo.Borkowski at gmx.de> wrote:
> 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/38111a4f/attachment.html
More information about the stringtemplate-interest
mailing list