1

I want to put several template files on a directory named "Templates", relative to the executable of my application, and use them. One template file, for instance, is named "Globals.st".

That way, I created a TemplateGroupDirectory and loaded the template:

var group = new TemplateGroupDirectory("Templates");
var tmpl = group.GetInstanceOf("Globals");

On trying to get the instance of the template I've got a message saying that occurs a NullReferenceException.

What am I missing?

Nilo Paim
  • 428
  • 6
  • 22

1 Answers1

1

might be a syntax thing

heres an example:

string fullpath = Path.GetFullPath("templates/");
TemplateGroupDirectory tgd = new TemplateGroupDirectory(fullpath ,'<','>');
Template t = tgd.GetInstanceOf("helloworld");
t.Add("world", "shitty world");

i have a folder to named templates, with the file helloworld.st that contains

helloworld(world) ::= <<
hello, <world>
>>

My best guess is that it cannot find the .st file you need, remember to put copy on newer or always coby, on the .st files' properties, when you use relative paths, or else template will be nothing.

  • I'll try your code later. Thanks for your answer, but I'm not confident. I've had tried to use the full path before and it gives me the same error. And yes, I'd copied the files on each build of the project, with the same errors. Thanks anyway. – Nilo Paim Jun 09 '15 at 20:19