freemarker-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Dekany <ddek...@apache.org>
Subject Re: [FM3] Solving FM2 caching problems due to locale etc.
Date Sun, 26 Mar 2017 11:12:32 GMT
Sunday, March 26, 2017, 9:36:17 AM, Denis Bredelet wrote:

> Hi,
>
>>> Template.process(...) would be removed, as it's not the duty of the
>>> Template to create the Environment anymore.
>>> 
>>> On the level of the more expert Environment API, this translates to
>>> something like this:
>>> 
>>>    Environment env = new Environment(cfg, dataModel, out);
>>>    env.setLocale(aLocale);
>>>    env.setCustomLookupCondition(aLookupCondition);
>>>    ... // Addjust env further
>>>    env.loadMainTemplate(name); // After setting locale and customLookupCond!
>>>    env.process();
>>>    ... // Get back variables from env if you want
>> This looks a lot clearer and more intuitive to me!
>> 
>
> The last two lines do not seem intuitive for me. What do they do?

1. loadMainTemplate gets a Template (from the TemplateResolver) and
   sets it as the main template of the Environment.
2. process runs the main template of the Environment.

What exactly is confusing about it? I'm asking so that we can make it
more intuitive.

> — Denis.
>
>>> 
>>> You might notice that Environment now stores the
>>> customLookupCondition, while in FM2 the Template stores it. Any
>>> template loading from the Environment will happen with that condition
>>> (and with env.locale, just as in FM2). In FM2 the
>>> customLookupCondition is inherited from the Template that contains the
>>> #import/#include statement, but if you think about it, the end results
>>> is practically the same.
>> Yeah, it's really cool concepts now. Very exciting!!
>> 
>> Cheers,
>> 
>> Woonsan
>

-- 
Thanks,
 Daniel Dekany


Mime
View raw message