[stringtemplate-interest] Including templates from other directories
Terence Parr
parrt at cs.usfca.edu
Tue Sep 16 17:29:45 PDT 2008
well, you can have a group with subdirs...then ref $a/body()$ I believe.
Ter
On Sep 16, 2008, at 3:28 PM, jingzhao.ou wrote:
> Hi, all,
>
> I am new to StringTemplate. I searched but was unable to find answers
> to my question. That is why I am posting here.
>
> What I want to do is very simple. I have a template in directory a:
>
> $body()$
>
> Usually, this will look for another template body.st under directory
> a. However, for some reason, I want to put body.st in another
> directory b. I don't know how to write Java code to tell
> StringTemplate to look for templates in another directory.
>
> I try the following but with no luck: Can any one help me out?
>
> Thanks a lot!
> Jingzhao
>
> ========================
>
> File stgDir = new File(src, ".stg");
> if (stgDir.isDirectory()) {
> System.out.println("Loading StringTemplateGroup: " +
> stgDir.getCanonicalPath());
> StringTemplateGroup.loadGroup(stgDir.getCanonicalPath());
> }
>
> ......
>
> StringTemplate st = new StringTemplate(tpl);
> // turn off caching
> st.getGroup().setRefreshInterval(refreshInterval);
> // add some string manipulation utilities
> st.registerRenderer(String.class, new BasicFormatRenderer());
>
> st.setAttribute("T", data);
> String result = st.toString();
> _______________________________________________
> 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