37 # what's up with that, but that is not that critical. Should38 # be fixed though.39 self.assert_traceback_matches(lambda: env.get_template('syntaxerror.html'), r'''(?sm)40 File ".*?syntaxerror.html", line 4, in (template|<module>)41- \{% endif %\}42- .*?41+ \{% endif %\}.*?42(jinja2\.exceptions\.)?TemplateSyntaxError: Encountered unknown tag 'endif'. Jinja was looking for the following tags: 'endfor' or 'else'. The innermost block that needs to be closed is 'for'.43 ''')4445 def test_regular_syntax_error(self):
1-Todo Before Release2-===================3-4-This has to be implemented before the release:5-6-Pull Attributes Onces7----------------------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 None19- 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 lookups24-(it tries getitem/getattr and in sandbox mode also permissions) multiple25-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 None31- yield u'\n %s\n' % (32- l_baz(t1),33- )34-35-However that should only happen if the attribute is accessed multiple times36-unlike locals and filters/tests which are always pulled. We're not doing that37-for filters/tests/locals as nested scopes may access it and testing is too38-complicated for the tiny performance improvement but easy for attribute39-lookups, keeping the complexity of the whole thing in mind.