[
https://issues.apache.org/jira/browse/FREEMARKER-60?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16074017#comment-16074017
]
Daniel Dekany commented on FREEMARKER-60:
-----------------------------------------
I have added a notice regarding {{#global}} to the Javadoc of the
{{lazyImports}} setting.
Indicating laziness/eagerness in the {{#import}} tag is technically possible,
but I don't yet see the practical application of that, because if for an
imported template laziness is a problem, then certainly it's a problem on all
places where it's imported. Keeping all imports of a certain template eager
manually would be a maintenance burden. (Also that you can import things
without {{#import}}, such as with {{Environment}} API or with {{auto_imports}}
setting, complicates things further, as we had to add an extra parameter on all
those places.)
So I guess the best solution would be something like a {{forced_eager_imports}}
setting where you list the patterns of the imports that aren't compatible with
laziness. (I think that imports always should have lazy by default, that's why
I apparently think a bit backwards, that is, I assume that the norm is that
everything is lazy, and the exceptions are those who can't be.) Would this
approach work well in your case?
> Document interaction between lazy import and #global
> ----------------------------------------------------
>
> Key: FREEMARKER-60
> URL: https://issues.apache.org/jira/browse/FREEMARKER-60
> Project: Apache Freemarker
> Issue Type: Improvement
> Components: documentation
> Affects Versions: 2.3.26-incubating
> Reporter: Jasper Rosenberg
> Priority: Trivial
>
> If I am understanding what is going on correctly, it appears that when you
> turn on lazy imports, #global variables defined in that file will not be
> defined unless something else first accesses the imported file's namespace.
> This is a bit of a weird case so it might just be worth documenting.
> Alternatively, you could say that if you have #global variables defined in a
> file it disqualifies it from being lazily imported.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)