Lex the given sourcecode and return a generator that yields tokens as tuples in the form ``(lineno, token_type, value)``. This can be useful for :ref:`extension development ` and debugging templates. This does not perform preprocessing. If you wa
(self, source, name=None, filename=None)
| 497 | return Parser(self, source, name, encode_filename(filename)).parse() |
| 498 | |
| 499 | def lex(self, source, name=None, filename=None): |
| 500 | """Lex the given sourcecode and return a generator that yields |
| 501 | tokens as tuples in the form ``(lineno, token_type, value)``. |
| 502 | This can be useful for :ref:`extension development <writing-extensions>` |
| 503 | and debugging templates. |
| 504 | |
| 505 | This does not perform preprocessing. If you want the preprocessing |
| 506 | of the extensions to be applied you have to filter source through |
| 507 | the :meth:`preprocess` method. |
| 508 | """ |
| 509 | source = text_type(source) |
| 510 | try: |
| 511 | return self.lexer.tokeniter(source, name, filename) |
| 512 | except TemplateSyntaxError: |
| 513 | exc_info = sys.exc_info() |
| 514 | self.handle_exception(exc_info, source_hint=source) |
| 515 | |
| 516 | def preprocess(self, source, name=None, filename=None): |
| 517 | """Preprocesses the source with all extensions. This is automatically |
no test coverage detected