Mercurial > piecrust2
view piecrust/templating/jinja/loader.py @ 854:08e02c2a2a1a
core: Keep refactoring, this time to prepare for generator sources.
- Make a few APIs simpler.
- Content pipelines create their own jobs, so that generator sources can
keep aborting in `getContents`, but rely on their pipeline to generate
pages for baking.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 04 Jun 2017 23:34:28 -0700 |
parents | 2c7e57d80bba |
children | 1bb704434ee2 |
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.segment_parts_cache = {} def get_source(self, environment, template): if template.startswith('$part='): filename, seg_part = self.segment_parts_cache[template] mtime = os.path.getmtime(filename) def uptodate(): try: return os.path.getmtime(filename) == mtime except OSError: return False return seg_part, filename, uptodate return super(PieCrustLoader, self).get_source(environment, template)