[stringtemplate-interest] proper stringtemplate loading from a webapp
Dave Rafkind
dave.rafkind at gmail.com
Sun Feb 3 18:51:03 PST 2008
Well, I was hoping to load resources that aren't in the WEB-INF/classes
directory, sort of replacing .JSP pages with .st pages, so I'm trying to
avoid class-path based loading.
Could I subclass StringTemplateGroup and just override the
loadTemplateFromBeneathRootDirOrCLASSPATH() function (which looks like
it does the actual work)? Or would that make things too complicated?
Terence Parr wrote:
> 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