Permalink
Browse files

Fixed a confusing edge case (thanks apollo13)

--HG--
branch : trunk
  • Loading branch information...
mitsuhiko committed Sep 15, 2008
1 parent 57c9b6d commit 3213355aef195818c282dabe51dfd5694c26d5f6
Showing with 18 additions and 7 deletions.
  1. +8 −0 CHANGES
  2. +3 −3 jinja2/compiler.py
  3. +7 −4 jinja2/ext.py
View
@@ -18,6 +18,14 @@ Version 2.1
undefined object now instead of raising an index error. This was a bug
caused by eager optimizing.
+- the i18n extension looks up `foo.ugettext` now followed by `foo.gettext`
+ if an translations object is installed. This makes dealing with custom
+ translations classes easier.
+
+- fixed a confusing behavior with conditional extending. loops were partially
+ executed under some conditions even though they were not part of a visible
+ area.
+
Version 2.0
-----------
(codename jinjavitus, released on July 17th 2008)
View
@@ -1051,7 +1051,7 @@ def visit_ExprStmt(self, node, frame):
def visit_Output(self, node, frame):
# if we have a known extends statement, we don't output anything
- if self.has_known_extends and frame.toplevel:
+ if self.has_known_extends and frame.block is None:
return
if self.environment.finalize:
@@ -1061,11 +1061,11 @@ def visit_Output(self, node, frame):
self.newline(node)
- # if we are in the toplevel scope and there was already an extends
+ # if we are not in a block and there was already an extends
# statement we have to add a check that disables our yield(s) here
# so that they don't appear in the output.
outdent_later = False
- if frame.toplevel and self.extends_so_far != 0:
+ if frame.block is None and self.extends_so_far != 0:
self.writeline('if parent_template is None:')
self.indent()
outdent_later = True
View
@@ -142,10 +142,13 @@ def __init__(self, environment):
)
def _install(self, translations):
- self.environment.globals.update(
- gettext=translations.ugettext,
- ngettext=translations.ungettext
- )
+ gettext = getattr(translations, 'ugettext', None)
+ if gettext is None:
+ gettext = translations.gettext
+ ngettext = getattr(translations, 'ungettext', None)
+ if ngettext is None:
+ ngettext = translations.ngettext
+ self.environment.globals.update(gettext=gettext, ngettext=ngettext)
def _install_null(self):
self.environment.globals.update(

0 comments on commit 3213355

Please sign in to comment.