Is it possible to make a custom renderer for StringTemplate without using STGroup's?

536 Views Asked by At

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();
1

There are 1 best solutions below

0
On BEST ANSWER

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();