views:

119

answers:

1

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?

+1  A: 

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

kohomologie
Is it possible to load the template from an embedded file inside an assembly?
Amitabh
See section "Loading Templates relative to the Assembly's Location" here: http://www.antlr.org/wiki/display/ST/Defining+Templates
kohomologie
Unfortunately even after giving the Absolute path I am unable to load the template.
Amitabh