Source

jinja2 / TODO

Todo Before Release
===================

This has to be implemented before the release:

Pull Attributes Onces
---------------------

Imagine the following template::

    {% if foo.bar %}
        {{ baz(foo.bar) }}
    {% endif %}

Problem with that is that it compiles to this::

    if environment.subscribe(l_foo, 'bar'):
        if 0: yield None
        yield u'\n    %s\n' % (
            l_baz(environment.subscribe(l_foo, 'bar')),
        )

As `environment.subscribe` is more expensive then regular attribute lookups
(it tries getitem/getattr and in sandbox mode also permissions) multiple
lookups with the same parameters in the same scope should get local aliases.
The result we have is that one::

    t1 = environment.subscribe(l_foo, 'bar')
    if t1:
        if 0: yield None
        yield u'\n    %s\n' % (
            l_baz(t1),
        )

However that should only happen if the attribute is accessed multiple times
unlike locals and filters/tests which are always pulled.  We're not doing that
for filters/tests/locals as nested scopes may access it and testing is too
complicated for the tiny performance improvement but easy for attribute
lookups, keeping the complexity of the whole thing in mind.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.