[stringtemplate-interest] proper stringtemplate loading from a webapp

Terence Parr parrt at cs.usfca.edu
Thu Jan 31 10:19:22 PST 2008


Hi. I think you can just use null as root dir.  A comment i see in  
code says: "If there is no root directory, try to load the template  
from the classpath."

Try that...

Ter
On Jan 31, 2008, at 7:23 AM, Dave Rafkind wrote:

> Hi list, I apologize if this question has been answered before, I'm
> having trouble getting good list search results out of google. But  
> anyways:
>
> The normal StringTemplateGroup constructor looks like:
>
> StringTemplateGroup stg = new  
> StringTemplateGroup(name,hard_coded_path);
>
> I'd like to avoid hardcoding that path in my web application, and
> instead create a custom template loader to get at the files the  
> "right"
> way which would be something like (from in a servlet):
>
>  context = getServletContext();
>  URL templateRoot = context.getResource("/templates");
>  StringTemplateGroup stg =
>    new StringTemplateGroup(name, templateRoot);
>
> which would use templateRoot.getUrlConnection() to get the
> stringtemplate files instead of a File() object.
>
> How would I go about doing such a thing?
>
>
> Thanks,
> Dave
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest



More information about the stringtemplate-interest mailing list