Added the `meta` module.
authorArmin Ronacher <armin.ronacher@active-4.com>
Sun, 26 Jul 2009 08:33:36 +0000 (10:33 +0200)
committerArmin Ronacher <armin.ronacher@active-4.com>
Sun, 26 Jul 2009 08:33:36 +0000 (10:33 +0200)
--HG--
branch : trunk

CHANGES
docs/api.rst
docs/conf.py
docs/jinjaext.py
jinja2/nodes.py

diff --git a/CHANGES b/CHANGES
index b218e87185c51fa23f3d787b611f6a2c7ed1cb90..b8450fcc1a629075849ffb36a580ec5b0dc26547 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -20,6 +20,7 @@ Version 2.2
   *before* the loop.  (#331)
 - Added support for optional `scoped` modifier to blocks.
 - Added support for line-comments.
+- Added the `meta` module.
 
 Version 2.1.1
 -------------
index 5383293f64edca17669eb538caa9c0661bc2593e..5a1e29acebec293551645d865427a96e6c0ee64e 100644 (file)
@@ -665,3 +665,17 @@ don't recommend using any of those.
     change it in a backwards incompatible way but modifications in the Jinja2
     core may shine through.  For example if Jinja2 introduces a new AST node
     in later versions that may be returned by :meth:`~Environment.parse`.
+
+The Meta API
+------------
+
+.. versionadded:: 2.2
+
+The meta API returns some information about abstract syntax trees that
+could help applications to implement more advanced template concepts.  All
+the functions of the meta API operate on an abstract syntax tree as
+returned by the :meth:`Environment.parse` method.
+
+.. autofunction:: jinja2.meta.find_undeclared_variables
+
+.. autofunction:: jinja2.meta.find_referenced_templates
index 3bd30e1191c9686f4416c6efbb8506f587272c0f..ba90c49a6be606f98dada62acd5955001dedd032 100644 (file)
@@ -95,9 +95,6 @@ html_last_updated_fmt = '%b %d, %Y'
 # typographically correct entities.
 #html_use_smartypants = True
 
-# use jinja2 for templates
-template_bridge = 'jinjaext.Jinja2Bridge'
-
 # no modindex
 html_use_modindex = False
 
index 212c8bfb353e2efe19031ed52274464ee951fb1b..66f4ba11652f5a255c6118cc58d63fcaadd2f838 100644 (file)
@@ -77,16 +77,6 @@ class JinjaStyle(Style):
     }
 
 
-class Jinja2Bridge(TemplateBridge):
-
-    def init(self, builder):
-        path = builder.config.templates_path
-        self.env = Environment(loader=FileSystemLoader(path))
-
-    def render(self, template, context):
-        return self.env.get_template(template).render(context)
-
-
 _sig_re = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*(\(.*?\))')
 
 
index c7858b6e5b1a5e7ba90d2c251a66de78bbb594d8..7c6c23012f5d1682add4acdfc379cb0ed4ed1bad 100644 (file)
@@ -146,7 +146,9 @@ class Node(object):
             return result
 
     def find_all(self, node_type):
-        """Find all the nodes of a given type."""
+        """Find all the nodes of a given type.  If the type is a tuple,
+        the check is performed for any of the tuple items.
+        """
         for child in self.iter_child_nodes():
             if isinstance(child, node_type):
                 yield child