Re: Writing an [@include] directive

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Thursday, June 30, 2011, 10:51:25 PM, Chris wrote:

> We have to write our own [@include] directive and I'm having problems.
>
> The reason we need to do this is that each file we include needs to have
> its own datamodel, and not necessarily use the parent datamodel. We've
> also got to bypass the default template loading and template caching code.

Out of curiosity, why?

> I'm running into problems. If I try to fetch and process an external 
> template from within a TemplateDirectiveModel, it fails to process more
> than one @include in a file. I'm having a hard time tracing the problem,
> but I suspect it's because the Environment is shared between the parent
> template and the included template. Environment is stored in a static 
> thread local variable. This is just a guess.

I'm not sure what are you trying to do. It's possible to create a new
environment within an existing environment. They won't be aware of
each-other. The thread-local is stored and restored by the "process"
method, so there shouldn't be a conflict, unless somehow you access
the outer environment from the inner one.

> If I put env.include(myIncludedTemplate) within the body of the 
> TemplateDirectiveModel it works, but it makes it hard to swap datamodels.
>
> Any thoughts or insight would be appreciated.

-- 
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
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.