]> git.ipfire.org Git - thirdparty/jinja.git/commit
Allow symbols to be overwritten by the environment
authorKevin Brown <kevin@kevin-brown.com>
Fri, 15 May 2020 16:27:10 +0000 (12:27 -0400)
committerKevin Brown <kevin@kevin-brown.com>
Fri, 15 May 2020 16:27:10 +0000 (12:27 -0400)
commita0364dd0190fd50551e1ee27f4f2cc2c32c7c5b3
tree136d18189348ae3d67e8bba6915b03e33c32d0ae
parent52a618e5872a424fdb4ed1519e82b4a45a4522d0
Allow symbols to be overwritten by the environment

This introduces a change to both the grammar and the parsing
environment that allows people to override start/end symbols in the
grammar through the environment. This finally brings the parser on
the same level as the old parser and lexer when it comes to handling
those customizations.

This means that the grammar must be compiled dynamically to account
for these customizations per environment. A module-level LRU cache
has been implemented to handle this fact, so grammars can be cached
instead of compiled every time. This should handle most cases other
than the unit tests, since most people aren't frequently changing up
their environment within their applications.

This also adds proper handling to the closing line block statement
so it waits for the end of a line or the end of the expression.
grammar.ebnf
src/jinja2/environment.py
src/jinja2/parser.py