preparing the big 2.0 release
[jinja2.git] / TODO
1 Todo Before Release
2 ===================
3
4 This has to be implemented before the release:
5
6 Pull Attributes Onces
7 ---------------------
8
9 Imagine the following template::
10
11     {% if foo.bar %}
12         {{ baz(foo.bar) }}
13     {% endif %}
14
15 Problem with that is that it compiles to this::
16
17     if environment.subscribe(l_foo, 'bar'):
18         if 0: yield None
19         yield u'\n    %s\n' % (
20             l_baz(environment.subscribe(l_foo, 'bar')),
21         )
22
23 As `environment.subscribe` is more expensive then regular attribute lookups
24 (it tries getitem/getattr and in sandbox mode also permissions) multiple
25 lookups with the same parameters in the same scope should get local aliases.
26 The result we have is that one::
27
28     t1 = environment.subscribe(l_foo, 'bar')
29     if t1:
30         if 0: yield None
31         yield u'\n    %s\n' % (
32             l_baz(t1),
33         )
34
35 However that should only happen if the attribute is accessed multiple times
36 unlike locals and filters/tests which are always pulled.  We're not doing that
37 for filters/tests/locals as nested scopes may access it and testing is too
38 complicated for the tiny performance improvement but easy for attribute
39 lookups, keeping the complexity of the whole thing in mind.