Mercurial > piecrust2
comparison piecrust/templating/pystacheengine.py @ 454:96d363e2da4b
templating: Let Jinja2 cache the parsed template for page contents.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 06 Jul 2015 21:32:40 -0700 |
parents | 32c7c2d219d2 |
children | 9d1a89cd8146 |
comparison
equal
deleted
inserted
replaced
453:8351a77e13f5 | 454:96d363e2da4b |
---|---|
14 EXTENSIONS = ['mustache'] | 14 EXTENSIONS = ['mustache'] |
15 | 15 |
16 def __init__(self): | 16 def __init__(self): |
17 self.renderer = None | 17 self.renderer = None |
18 | 18 |
19 def renderString(self, txt, data, filename=None): | 19 def renderSegmentPart(self, path, seg_part, data): |
20 self._ensureLoaded() | 20 self._ensureLoaded() |
21 try: | 21 try: |
22 return self.renderer.render(txt, data) | 22 return self.renderer.render(seg_part.content, data) |
23 except pystache.common.TemplateNotFoundError as ex: | 23 except pystache.common.TemplateNotFoundError as ex: |
24 raise TemplateNotFoundError() from ex | 24 raise TemplateNotFoundError() from ex |
25 except pystache.common.PystacheError as ex: | 25 except pystache.common.PystacheError as ex: |
26 raise TemplatingError(str(ex), filename) from ex | 26 raise TemplatingError(str(ex), path) from ex |
27 | 27 |
28 def renderFile(self, paths, data): | 28 def renderFile(self, paths, data): |
29 self._ensureLoaded() | 29 self._ensureLoaded() |
30 tpl = None | 30 tpl = None |
31 logger.debug("Looking for template: %s" % paths) | 31 logger.debug("Looking for template: %s" % paths) |