Re: Best way to pass parameter to custom TemplateLoader?
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Tuesday, July 12, 2011, 9:45:54 AM, Daniel Dekany wrote: > You should encode the relevant information from the HttpServletRequest > into the template name. For example, you could have template names > like "tree1://foo/bar.ftl" and "tree2://foo/bar.ftl" and so on. Then > your TemplateLoader should delegate to other TemplateLoader-s based on > the part before the "://" (which can be anything BTW, like even > "user=joe,application=accounting://"). If you wonder why > "tree1://foo/bar.ftl" is better than "tree1/foo/bar.ftl", it's because > absolute paths in bar.ftl, like in <#import "/baaz.ftl" as b>, will be > resolved to "tree1://baaz.ftl" in the first case, but to "baaz.ftl", I meant "but to "baaz.ftl in the second case"... > which is not correct. (You could still do cross-tree inclusions > explicitly, like with "tree2://something.ftl".) Regarding the thread-local issue with Jetty... I can't believe that it messes with executing several request executed in the same thread interleaved. That would be terrible as many already existing libraries use TLS, and now those would produce obscure random glitches. It would cause problems for FreeMarker too, as it relies on TLS for passing the Environment to TemplateModel methods that has no Environment parameter. -- Best regards, Daniel Dekany ------------------------------------------------------------------------------ All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2d-c2