[prev in list] [next in list] [prev in thread] [next in thread]
List: stringtemplate-interest
Subject: [stringtemplate-interest] proper stringtemplate loading from a
From: parrt () cs ! usfca ! edu (Terence Parr)
Date: 2008-02-04 18:27:01
Message-ID: 8536D62B-1F4A-4408-A5B2-7E3D048C6738 () cs ! usfca ! edu
[Download RAW message or body]
Hi. I would suggest using a StringTemplateGroupLoader. These were
designed so that you could load templates from wherever you want.
Ter
On Feb 3, 2008, at 6:51 PM, Dave Rafkind wrote:
> 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
>>
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org:8080/mailman/listinfo/stringtemplate-interest
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic