开发者

StringTemplate: Loading a Template from disk?

开发者 https://www.devze.com 2023-01-02 23:38 出处:网络
I am using StringTemplate in c# and following code to load a template from a subdirectory of my application.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消