StringTemplate: Loading a Template from disk?
I am using StringTemplate in c# and following code to load a template from a subdirectory of my application.
StringTemplateGroup group = new StringTemplateGroup("myGroup", "/tmp");
StringTemplate query = group.GetInstanceOf("Sample");
query.SetAttribute("column", "name");
Console开发者_开发技巧.WriteLine(query);
I have a template file Sample.st in the tmp directory of my application.
I am getting the following error.
Unhandled Exception: System.ArgumentException: Can't find template Sample.st; group hierarchy is [myGroup]
Does anyone know what is wrong here?
Probably you should specify absolute path as a second parameter for StringTemplateGroup
constructor?
In addition to adding a reference to the Antlr3.StringTemplate assembly, you ALSO need to add a reference to the Antlr3.Runtime assembly (not necessarily the Antlr3.Runtime.Debug assembly, although this would also work). This worked for me.
精彩评论