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)
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:
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
)
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(