diff piecrust/templating/jinja/loader.py @ 924:1bb704434ee2

formatting: Remove segment parts, you can use template tags instead. Segment parts were used to switch formatters insides a given content segment, but that's also achievable with template tags like `pcformat` in Jinja to some degree. It's not totally the same but removing it simplifies the code and improves performance.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 01 Oct 2017 20:36:04 -0700
parents 2c7e57d80bba
children
line wrap: on
line diff
--- a/piecrust/templating/jinja/loader.py	Fri Sep 29 19:59:19 2017 -0700
+++ b/piecrust/templating/jinja/loader.py	Sun Oct 01 20:36:04 2017 -0700
@@ -5,11 +5,11 @@
 class PieCrustLoader(FileSystemLoader):
     def __init__(self, searchpath, encoding='utf-8'):
         super(PieCrustLoader, self).__init__(searchpath, encoding)
-        self.segment_parts_cache = {}
+        self.segments_cache = {}
 
     def get_source(self, environment, template):
-        if template.startswith('$part='):
-            filename, seg_part = self.segment_parts_cache[template]
+        if template.startswith('$seg='):
+            filename, seg_content = self.segments_cache[template]
 
             mtime = os.path.getmtime(filename)
 
@@ -19,6 +19,6 @@
                 except OSError:
                     return False
 
-            return seg_part, filename, uptodate
+            return seg_content, filename, uptodate
 
         return super(PieCrustLoader, self).get_source(environment, template)