Question

I'm trying to use StringTemplate to be able to parse some configuration file inputs, and was wondering if it was possible to register a renderer without using STGroup.

Example (but the registerRenderer method seems to be missing from the library):

ST myST = new ST("Hello, <thing>!");
myST.add("thing", new Thing());
myST.registerRenderer(Thing.class, new ThingRenderer());
return myST.render();
Was it helpful?

Solution

Actually after posting this, the answer came to me.

STGroup myGroup = new STGroup();
myGroup.registerRenderer(Thing.class, new ThingRenderer());
ST myST = new ST(myGroup, "Hello, <thing>!");
myST.add("thing", new Thing());
return myST.render();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top