Mercurial > piecrust2
changeset 59:e3e3de44377c
Better handling of Jinja configuration.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 26 Aug 2014 23:20:19 -0700 |
parents | 95590732e4c9 |
children | 6e60e0fef2be |
files | piecrust/templating/jinjaengine.py |
diffstat | 1 files changed, 15 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/piecrust/templating/jinjaengine.py Tue Aug 26 23:18:58 2014 -0700 +++ b/piecrust/templating/jinjaengine.py Tue Aug 26 23:20:19 2014 -0700 @@ -54,17 +54,28 @@ raise TemplateNotFoundError() return tpl.render(data) - def _ensureLoaded(self): if self.env: return + + autoescape = self.app.config.get('jinja/auto_escape') + if autoescape is None: + autoescape = self.app.config.get('twig/auto_escape') + if autoescape is None: + autoescape = True + + logger.debug("Creating Jinja environment with folders: %s" % + self.app.templates_dirs) loader = FileSystemLoader(self.app.templates_dirs) + extensions = [ + PieCrustHighlightExtension, + PieCrustCacheExtension] + if autoescape: + extensions.append('jinja2.ext.autoescape') self.env = PieCrustEnvironment( self.app, loader=loader, - extensions=['jinja2.ext.autoescape', - PieCrustHighlightExtension, - PieCrustCacheExtension]) + extensions=extensions) class PieCrustEnvironment(Environment):