freemarker-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Denis Bredelet <brede...@mac.com>
Subject Re: [FM3] Solving FM2 caching problems due to locale etc.
Date Sun, 26 Mar 2017 18:33:57 GMT
Hi Daniel,

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

In the current environment I do not think there is a main template. Is that new? Does it contain
the template text? What can you do with it? Can you access it as text?

Next, the process method seems to run the main template. If that is its function then the
name should reflect that.

Conceptually, do you want the environment to be a container for the main template or does
it have another purpose?

I don’t like using a class which serves more than one main purpose — too comparable to
kitchen sink for my liking.

Thanks,
— Denis.

>> — 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message