[stringtemplate-interest] Embedded loader problems
brian at protexis.com
brian at protexis.com
Mon Aug 28 14:39:09 PDT 2006
Hi
Suppose I create two templates (One.st and Two.st) and a template group
(Common.stg)
The contents of One.st are as follows:
$Two()$
The contents of Two.st are as follows:
"I'm not having fun here"
The contents of Common.stg are as follows:
group Common;
Here's the C# code:
Assembly assembly = Assembly.GetExecutingAssembly();
// define the loader for the string template group
EmbeddedResourceGroupLoader embeddedResourceGroupLoader = new
EmbeddedResourceGroupLoader(
null,
assembly,
WebPageResource.TemplateGroupNameSpace);
StringTemplateGroup stringTemplateGroup =
embeddedResourceGroupLoader.LoadGroup(
WebPageConstant.GROUP_TYPE_NAME);
// define the loader for the string template
EmbeddedResourceTemplateLoader embeddedResourceTemplateLoader = new
EmbeddedResourceTemplateLoader(
assembly,
WebPageResource.TemplateNameSpace);
StringTemplate stringTemplate = new StringTemplate(
stringTemplateGroup,
embeddedResourceTemplateLoader.LoadTemplate(templateTypeName));
When I run the code with templateTypeName set to "One", an exception is
thrown because the StringTemplate class has no idea where "Two.st" is
located.
Could someone please point me in the right direction? What do I need to do
to get the output "I'm not having fun here"?
If the StringTemplate library doesn't support thing, can I add another
constructor to the StringTemplate class that takes a StringTemplateLoader
as a parameter?
Thanks
More information about the stringtemplate-interest
mailing list