Mercurial > piecrust2
comparison piecrust/templating/jinjaengine.py @ 528:cf3218766fe2
bug: Of course I broke something. Some exceptions need to pass through Jinja.
| author | Ludovic Chabant <ludovic@chabant.com> |
|---|---|
| date | Tue, 28 Jul 2015 22:09:13 -0700 |
| parents | 4bca25f99463 |
| children | 63ae5eae90ca |
comparison
equal
deleted
inserted
replaced
| 527:fa9eb8f866cd | 528:cf3218766fe2 |
|---|---|
| 13 from compressinja.html import HtmlCompressor, StreamProcessContext | 13 from compressinja.html import HtmlCompressor, StreamProcessContext |
| 14 from pygments import highlight | 14 from pygments import highlight |
| 15 from pygments.formatters import HtmlFormatter | 15 from pygments.formatters import HtmlFormatter |
| 16 from pygments.lexers import get_lexer_by_name, guess_lexer | 16 from pygments.lexers import get_lexer_by_name, guess_lexer |
| 17 from piecrust.data.paginator import Paginator | 17 from piecrust.data.paginator import Paginator |
| 18 from piecrust.environment import AbortedSourceUseError | |
| 18 from piecrust.rendering import format_text | 19 from piecrust.rendering import format_text |
| 19 from piecrust.routing import CompositeRouteFunction | 20 from piecrust.routing import CompositeRouteFunction |
| 20 from piecrust.templating.base import (TemplateEngine, TemplateNotFoundError, | 21 from piecrust.templating.base import (TemplateEngine, TemplateNotFoundError, |
| 21 TemplatingError) | 22 TemplatingError) |
| 22 from piecrust.uriutil import multi_replace, split_sub_uri | 23 from piecrust.uriutil import multi_replace, split_sub_uri |
| 51 | 52 |
| 52 try: | 53 try: |
| 53 return tpl.render(data) | 54 return tpl.render(data) |
| 54 except TemplateSyntaxError as tse: | 55 except TemplateSyntaxError as tse: |
| 55 raise self._getTemplatingError(tse) | 56 raise self._getTemplatingError(tse) |
| 57 except AbortedSourceUseError: | |
| 58 raise | |
| 56 except Exception as ex: | 59 except Exception as ex: |
| 57 msg = "Error rendering Jinja markup" | 60 msg = "Error rendering Jinja markup" |
| 58 rel_path = os.path.relpath(path, self.app.root_dir) | 61 rel_path = os.path.relpath(path, self.app.root_dir) |
| 59 raise TemplatingError(msg, rel_path) from ex | 62 raise TemplatingError(msg, rel_path) from ex |
| 60 | 63 |
| 78 | 81 |
| 79 try: | 82 try: |
| 80 return tpl.render(data) | 83 return tpl.render(data) |
| 81 except TemplateSyntaxError as tse: | 84 except TemplateSyntaxError as tse: |
| 82 raise self._getTemplatingError(tse) | 85 raise self._getTemplatingError(tse) |
| 86 except AbortedSourceUseError: | |
| 87 raise | |
| 83 except Exception as ex: | 88 except Exception as ex: |
| 84 msg = "Error rendering Jinja markup" | 89 msg = "Error rendering Jinja markup" |
| 85 rel_path = os.path.relpath(rendered_path, self.app.root_dir) | 90 rel_path = os.path.relpath(rendered_path, self.app.root_dir) |
| 86 raise TemplatingError(msg, rel_path) from ex | 91 raise TemplatingError(msg, rel_path) from ex |
| 87 | 92 |
