Mercurial > piecrust2
view piecrust/templating/jinja/loader.py @ 991:1857dbd4580f
bake: Fix bugs introduced by bake optimizations, of course.
- Make the execution stats JSON-serializable.
- Re-add ability to differentiate between sources used during segment rendering
and during layout rendering. Fixes problems with cache invalidation of
pages that use other sources.
- Make taxonomy-related stuff JSON-serializable.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 20 Nov 2017 23:06:47 -0800 |
parents | 1bb704434ee2 |
children |
line wrap: on
line source
import os.path from jinja2 import FileSystemLoader class PieCrustLoader(FileSystemLoader): def __init__(self, searchpath, encoding='utf-8'): super(PieCrustLoader, self).__init__(searchpath, encoding) self.segments_cache = {} def get_source(self, environment, template): if template.startswith('$seg='): filename, seg_content = self.segments_cache[template] mtime = os.path.getmtime(filename) def uptodate(): try: return os.path.getmtime(filename) == mtime except OSError: return False return seg_content, filename, uptodate return super(PieCrustLoader, self).get_source(environment, template)