Mercurial > piecrust2
comparison piecrust/templating/jinjaengine.py @ 855:448710d84121
refactor: Get the taxonomy support back to a functional state.
There's now a taxonomy content source that wraps another normal content source
like a blog posts' source. It works in tandem with a taxonomy content pipeline
that will do the heavy lifting of figuring out what kind of terms exist and
need to be baked.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 06 Jun 2017 00:26:21 -0700 |
parents | 4850f8c21b6e |
children | 5c5b85d4f17d |
comparison
equal
deleted
inserted
replaced
854:08e02c2a2a1a | 855:448710d84121 |
---|---|
82 filename = os.path.relpath(filename, self.env.app.root_dir) | 82 filename = os.path.relpath(filename, self.env.app.root_dir) |
83 err = TemplatingError(str(tse), filename, tse.lineno) | 83 err = TemplatingError(str(tse), filename, tse.lineno) |
84 raise err from tse | 84 raise err from tse |
85 | 85 |
86 def _ensureLoaded(self): | 86 def _ensureLoaded(self): |
87 if self.env: | 87 if self.env is not None: |
88 return | 88 return |
89 | 89 |
90 stats = self.app.env.stats | |
91 stats.registerTimer('JinjaTemplateEngineEnvironmentSetup', | |
92 raise_if_registered=False) | |
93 with stats.timerScope('JinjaTemplateEngineEnvironmentSetup'): | |
94 self._load() | |
95 | |
96 def _load(self): | |
97 get_config = self.app.config.get | |
98 | |
90 # Get the list of extensions to load. | 99 # Get the list of extensions to load. |
91 ext_names = self.app.config.get('jinja/extensions', []) | 100 ext_names = get_config('jinja/extensions', []) |
92 if not isinstance(ext_names, list): | 101 if not isinstance(ext_names, list): |
93 ext_names = [ext_names] | 102 ext_names = [ext_names] |
94 | 103 |
95 # Turn on autoescape by default. | 104 # Turn on autoescape by default. |
96 autoescape = self.app.config.get('twig/auto_escape') | 105 autoescape = get_config('twig/auto_escape') |
97 if autoescape is not None: | 106 if autoescape is not None: |
98 logger.warning("The `twig/auto_escape` setting is now called " | 107 logger.warning("The `twig/auto_escape` setting is now called " |
99 "`jinja/auto_escape`.") | 108 "`jinja/auto_escape`.") |
100 else: | 109 else: |
101 autoescape = self.app.config.get('jinja/auto_escape', True) | 110 autoescape = get_config('jinja/auto_escape', True) |
102 if autoescape: | 111 if autoescape: |
103 ext_names.append('autoescape') | 112 ext_names.append('autoescape') |
104 | 113 |
105 # Create the final list of extensions. | 114 # Create the final list of extensions. |
106 from piecrust.templating.jinja.extensions import ( | 115 from piecrust.templating.jinja.extensions import ( |