Added the `meta` module.
Before adoption: this commit came in with the history the project adopted, so no landing records it.
--HG-- branch : trunk
authored by Armin Ronacher · committed by Armin Ronacher · parent d1442c8 · Browse files · 5 files·+18 added−14 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+18 added−14 removed
- other:+18 added−14 removed
Provenance
- Commit
63cf9b8- Tree
f930155- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
d1442c8
5 files changed+18 added−14 removed
modified:docs/api.rst+14 added
663 unmodified lines664 The low-level API is fragile. Future Jinja2 versions will try not to665 change it in a backwards incompatible way but modifications in the Jinja2666 core may shine through. For example if Jinja2 introduces a new AST node667 in later versions that may be returned by :meth:`~Environment.parse`.668+669+The Meta API670+------------671+672+.. versionadded:: 2.2673+674+The meta API returns some information about abstract syntax trees that675+could help applications to implement more advanced template concepts. All676+the functions of the meta API operate on an abstract syntax tree as677+returned by the :meth:`Environment.parse` method.678+679+.. autofunction:: jinja2.meta.find_undeclared_variables680+681+.. autofunction:: jinja2.meta.find_referenced_templatesmodified:docs/conf.py-3 removed
93 unmodified lines94 # If true, SmartyPants will be used to convert quotes and dashes to95 # typographically correct entities.96 #html_use_smartypants = True97 98-# use jinja2 for templates99-template_bridge = 'jinjaext.Jinja2Bridge'100-98 # no modindex99 html_use_modindex = False100 101 # If true, the reST sources are included in the HTML build as _sources/<name>.40 unmodified linesmodified:docs/jinjaext.py-10 removed
75 unmodified lines76 Error: '#F00 bg:#FAA'77 }78 79 80-class Jinja2Bridge(TemplateBridge):81-82- def init(self, builder):83- path = builder.config.templates_path84- self.env = Environment(loader=FileSystemLoader(path))85-86- def render(self, template, context):87- return self.env.get_template(template).render(context)88-89-80 _sig_re = re.compile(r'^[a-zA-Z_][a-zA-Z0-9_]*(\(.*?\))')81 82 83 def format_function(name, aliases, func):109 unmodified linesmodified:jinja2/nodes.py+3 added-1 removed
144 unmodified lines145 for result in self.find_all(node_type):146 return result147 148 def find_all(self, node_type):149- """Find all the nodes of a given type."""149+ """Find all the nodes of a given type. If the type is a tuple,150+ the check is performed for any of the tuple items.151+ """152 for child in self.iter_child_nodes():153 if isinstance(child, node_type):154 yield child155 for result in child.find_all(node_type):636 unmodified linesmodified:CHANGES+1 added
18 unmodified lines19 variable and regular variable *after* the loop if that variable was unused20 *before* the loop. (#331)21 - Added support for optional `scoped` modifier to blocks.22 - Added support for line-comments.23+- Added the `meta` module.24 25 Version 2.1.126 -------------27 (Bugfix release)84 unmodified lines