Freemarker Template Organization Best Practices?

Keith Swallow <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Greetings All,

I followed the instructions provided by Daniel on adding a header and footer to a template. (http://thread.gmane.org/gmane.comp.web.freemarker.user/4797) Things are working well (thanks Daniel!) and I was just wondering if there is a best practice or usage pattern that would be better than what I am doing.

My idea was to organize my templates and macros where each section of the site has its own template path. Something like this:

/templateRoot/common.ftl
/templateRoot/myServlet/list.ftl <-- needs main.ftl for header and footer.

To achieve this I overrode the requestUrlToTemplatePath method on the FreemarkerServlet as follows.

@Override
protected String requestUrlToTemplatePath( final HttpServletRequest request ) {
    final String path = super.requestUrlToTemplatePath( request );
    return this.getClass().getSimpleName() + path;
};

Is there a better way to do this (or something similar)? I have looked for a Freemarker Best Practices and haven't found a whole lot.

Best,

Keith

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.