class Environment(object):
"""
- The jinja environment.
+ The Jinja environment.
The core component of Jinja is the `Environment`. It contains
important shared variables like configuration, filters, tests,
self.friendly_traceback = friendly_traceback
# global namespace
- self.globals = namespace is None and DEFAULT_NAMESPACE.copy() \
- or namespace
+ if namespace is None:
+ self.globals = DEFAULT_NAMESPACE.copy()
+ else:
+ self.globals = namespace
# jinja 1.0 compatibility
if auto_escape:
"""
return collect_translations(self.loader.parse(name))
+ def get_translations_for_string(self, string):
+ """
+ Like `get_translations`, but the translations are loaded from a
+ normal string that represents the template.
+ """
+ return collect_translations(self.parse(string))
+
def apply_filters(self, value, context, filters):
"""
Apply a list of filters on the variable.
"""
if value is Undefined or value is None:
return u''
+ elif getattr(value, 'jinja_no_finalization', False):
+ return value
val = self.to_unicode(value)
if self.default_filters:
val = self.apply_filters(val, ctx, self.default_filters)