[stringtemplate-interest] use template groups in a WAR
Nate
misc at n4te.com
Fri Nov 10 17:44:23 PST 2006
I am writing a web application. I want to use StringTemplate to generate
the HTML pages. I want users to be able to select a "skin" from a list.
Each skin would use a different set of templates to display the HTML.
My initial impression is that I'd use a different StringTemplateGroup
for each skin. I imagined a file structure like this...
skins/redtheme/page.st
skins/redtheme/etc.st
skins/bluetheme/page.st
skins/bluetheme/etc.st
...the code would be something like...
skinName = "redtheme";
group = new StringTemplateGroup(skinName, "skins");
group.getInstanceOf("page");
group.getInstanceOf("etc");
This works fine on the filesystem. Now I zip my application up into a
WAR file and suddenly the templates cannot be found. Next I think I
should look up templates using the classpath. StringTemplate
documentation leads me to think I need to use code like this...
skinName = "redtheme";
group = new StringTemplateGroup("allSkins");
group.getInstanceOf("skins/" + skinName + "/page");
group.getInstanceOf("skins/" + skinName + "/etc");
There is no "rootDir" when using the classpath, so I cannot use the a
StringTemplateGroup for each skin, like I could on the filesystem.
What is the solution? How do other people do it? Why does it work so
differently when JARed or WARed?
Regards,
Nathan Sweet
More information about the stringtemplate-interest
mailing list