[stringtemplate-interest] ST4: StaticMethodModelAdaptor

Collin Fagan collin.fagan at gmail.com
Fri Jan 21 17:57:26 PST 2011


Hi All,

While playing around with model adaptors I wrote one that "adds" properties
to a type from a static utility class. This ends up being something like a
"mix-in" or groovys meta-programming. Say you have a String in a template
variable called "string" and that variable had the value "hello world".
Using the StaticMethodModelAdaptor you could add all the compatible methods
from org.apache.commons.lang.StringUtils to String and call them from your
template.

Then <string.capitalise> would output: Hello world.

There is a demo program included that shows you what else can be done. I
like it, I hope you do too.

http://www.box.net/shared/rmoo5ia5b5

Collin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110121/d6777ed9/attachment-0001.html 


More information about the stringtemplate-interest mailing list