*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
-------------
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
# typographically correct entities.
#html_use_smartypants = True
-# use jinja2 for templates
-template_bridge = 'jinjaext.Jinja2Bridge'
-
# no modindex
html_use_modindex = False
}
-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_]*(\(.*?\))')
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