# HG changeset patch # User Ludovic Chabant # Date 1409120419 25200 # Node ID e3e3de44377c1ba8a2b8c07af4f1822581c43477 # Parent 95590732e4c939aa6d316a2bd7295fba840766f8 Better handling of Jinja configuration. diff -r 95590732e4c9 -r e3e3de44377c piecrust/templating/jinjaengine.py --- 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):