[stringtemplate-interest] ST4: Setting a model adapter on an "inline" template.

Udo Borkowski ub at abego-software.de
Wed Jan 26 06:49:49 PST 2011


Hi Collin,

try the "defineTemplate" methods in STGroup.

E.g.:

		STGroup g = new STGroup();
		g.registerModelAdaptor(ST.class, new MySTAdapter());
		g.defineTemplate("t","p","<p>");
		g.defineTemplate("main", "a<t(p=\"b\").hw>c");
		ST main = g.getInstanceOf("main");
		String actual = main.render();


Udo


On 26.01.2011, at 15:18, Collin Fagan wrote:

> Hi,
> 
> I am writing unit tests for my upcoming ST extensions project and I've run into a snag.
> 
> I would like to call new ST("template") and pass in a simple string for my template, but I also need to set a model adapter. So I know I need a STGroup but I can't seem to find a way to create a template from a string using a STGroup. The method createStringTemplate that takes a template as a parameter does not set model adapters or any thing like that, at lest not that I see. Is there a way to do this? I would very much like to not have to create template files for all or my tests.
> 
> Thanks,
> 
> Collin
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110126/6e04130d/attachment.html 


More information about the stringtemplate-interest mailing list