[stringtemplate-interest] use template groups in a WAR

Jean-Marie Renouard jmrenouard at gmail.com
Sun Nov 12 02:50:12 PST 2006


Hello,

Several solutions exist :
1) Use a jar for template in the WEB-INF/lib
2) place your templates in the classpath : WEB-INF/classes for example.
so in your case,
WEB-INF/classes/skins/...

Have a nice week :)
Jean-Marie

On 11/11/06, Nate <misc at n4te.com> wrote:
>
> 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
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
>



-- 
Cordialement,
Jean-Marie Renouard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20061112/b9789ef7/attachment.html 


More information about the stringtemplate-interest mailing list