[svn] various updates i haven't checked in so far (see the diff of the changelog...
[jinja2.git] / jinja / environment.py
index b390c01183ff9d48444169cfc8dc76e5292e5bcd..e1a057cd2fa4762c267b529c14a603ff0f069512 100644 (file)
@@ -24,7 +24,7 @@ __all__ = ['Environment']
 
 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,
@@ -136,8 +136,10 @@ class Environment(object):
         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:
@@ -227,6 +229,13 @@ class Environment(object):
         """
         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.
@@ -320,6 +329,8 @@ class Environment(object):
         """
         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)