[stringtemplate-interest] AttributeProvider interface

Collin Fagan collin.fagan at gmail.com
Thu Sep 1 06:44:16 PDT 2011


Yes as I said I've implemented model adapters to get results very much like
what I'm asking for.

But a model adapter only controls what happens 'after the dot'. I want to
provide the actual variables.

<beanFromSpring.dataIneed>

instead of

<context.beanFromSpring.dataIneed>

Collin

On Thu, Sep 1, 2011 at 8:35 AM, Sam Harwell <sharwell at pixelminegames.com>wrote:

> This was added in ST4 with the ModelAdaptor interface.****
>
> ** **
>
> Sam****
>
> ** **
>
> *From:* stringtemplate-interest-bounces at antlr.org [mailto:
> stringtemplate-interest-bounces at antlr.org] *On Behalf Of *Collin Fagan
> *Sent:* Thursday, September 01, 2011 7:47 AM
> *To:* stringtemplate-interest List
> *Subject:* [stringtemplate-interest] AttributeProvider interface****
>
> ** **
>
> Hi Everyone,
>
> I'd like to be able to bridge a StringTemplate to a source of data without
> explisitly calling add() for every object. As an example I would like to be
> able to add every bean from a Spring application context to the scope of a
> string template. I've built a model adapter that allows me to do this but I
> still must push in the application context into the template. This also
> forces me to do <context.beanIneed.property> instead or the much more
> natural <beanINeed.property>. Would it be possible to get an something like
> an "AttributeProvider" interface for an ST or STGroup that would allow me to
> do this?
>
> I'm thinking something like:
>
> public interface AttributeProvider {
>
> Object getAttribute(String name) throws NoSuchAttribute;
>
> }
>
> I know there have been discussions about formal parameters on templates and
> the few use cases where you might not want them. If you didn't have formal
> paramaters then injecting you template with it's dependencies with spring
> might be a good alternative.
>
> What do you think?
>
> Collin****
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110901/5aa78336/attachment.html 


More information about the stringtemplate-interest mailing list