Skip to content
Myr

Refactoring in the way the parse function is invoked.

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 eabf3dd · Browse files · 2 files+26 added−16 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+26 added−16 removed

  • other:+26 added−16 removed

2 files+26 added−16 removed

modified:jinja2/compiler.py+1 added-1 removed
604 unmodified lines
605 func_frame.identifiers.declared_parameter)606 )607 if overriden_closure_vars:608 self.fail('It\'s not possible to set and access variables '609 'derived from an outer scope! (affects: %s' %609 'derived from an outer scope! (affects: %s)' %610 ', '.join(sorted(overriden_closure_vars)), node.lineno)611612 # remove variables from a closure from the frame's undeclared613 # identifiers.
894 unmodified lines
modified:jinja2/environment.py+25 added-15 removed
363 unmodified lines
364365 If you are :ref:`developing Jinja2 extensions <writing-extensions>`366 this gives you a good overview of the node tree generated.367 """368 if isinstance(filename, unicode):369 filename = filename.encode('utf-8')368 try:371 return Parser(self, source, name, filename).parse()369 return self._parse(source, name, filename)370 except TemplateSyntaxError:371 exc_info = sys.exc_info()372 self.handle_exception(exc_info, source_hint=source)373374 def _parse(self, source, name, filename):375 """Internal parsing function used by `parse` and `compile`."""376 if isinstance(filename, unicode):377 filename = filename.encode('utf-8')378 return Parser(self, source, name, filename).parse()379380 def lex(self, source, name=None, filename=None):381 """Lex the given sourcecode and return a generator that yields382 tokens as tuples in the form ``(lineno, token_type, value)``.383 This can be useful for :ref:`extension development <writing-extensions>`
43 unmodified lines
427 parameter is `True` the return value will be a string with python428 code equivalent to the bytecode returned otherwise. This method is429 mainly used internally.430 """431 source_hint = None432 try:433 if isinstance(source, basestring):427 if isinstance(source, basestring):428 source = self.parse(source, name, filename)429 if self.optimized:430 source = optimize(source, self)431 source = generate(source, self, name, filename)432 if raw:433 return source434 if filename is None:435 filename = '<template>'436 elif isinstance(filename, unicode):437 filename = filename.encode('utf-8')438 return compile(source, filename, 'exec')434 source_hint = source435 source = self._parse(source, name, filename)436 if self.optimized:437 source = optimize(source, self)438 source = generate(source, self, name, filename)439 if raw:440 return source441 if filename is None:442 filename = '<template>'443 elif isinstance(filename, unicode):444 filename = filename.encode('utf-8')445 return compile(source, filename, 'exec')446 except TemplateSyntaxError:447 exc_info = sys.exc_info()448 self.handle_exception(exc_info, source_hint=source)449450 def compile_expression(self, source, undefined_to_none=True):451 """A handy helper method that returns a callable that accepts keyword452 arguments that appear as variables in the expression. If called it
437 unmodified lines