[stringtemplate-interest] AttributeProvider interface
Collin Fagan
collin.fagan at gmail.com
Thu Sep 1 05:47:03 PDT 2011
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/93b47ea0/attachment.html
More information about the stringtemplate-interest
mailing list