Search code examples
c#.netstringtemplate

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?


Solution

  • Probably you should specify absolute path as a second parameter for StringTemplateGroup constructor?