956181ca54ce — Oben Sonne 5 years ago
Minor code and doc improvments

- more descriptive variable naming
- slightly more compact code
2 files changed, 16 insertions(+), 17 deletions(-)

M README.md
M poole.py
M README.md +8 -6
@@ 78,8 78,8 @@ Run `poole.py --build` whenever you've m
 
 Poole takes files from a project's `input` directory and copies them to the
 `output` directory. In this process files ending with *md*, *mkd*, *mdown* or
-*markdown* get converted to HTML using the project's `page.html` as a skeleton,
-or define a custom layout skeleton for each page.
+*markdown* get converted to HTML using the project's `page.html` as a template
+(unless a custom template is set on an individual page).
 
 Additionally Poole expands any macros used in a page. Don't care about that for
 now ..

          
@@ 129,13 129,15 @@ It's easy to apply one of the numerous f
 site. For more information read [this blog post with step-by-step
 instructions][pimp].
 
-Additionally you can add the Property `layout` in the FrontMatter of each page:
+In case you need special templates for individual pages, you can add the
+property `tempalte` in the front matter of each page:
 
-    title: Some Title here
-    layout: custom_layout.html
+    title: This looks different
+    template: a-special-page-template.html
     ---
 
-In that case the given file is used as the page skeleton instead of the default `page.html` file.
+In that case the given file is used as the page template instead of the default
+`page.html` file.
 
 [pimp]: http://obensonne.bitbucket.org/blog/20091122-using-a-free-css-templates-in-poole.html
 

          
M poole.py +8 -11
@@ 623,26 623,23 @@ def build(project, opts):
     # -------------------------------------------------------------------------
 
     with codecs.open(opj(project, "page.html"), 'r', opts.input_enc) as fp:
-        skeleton = fp.read()
+        default_template = fp.read()
 
     for page in pages:
 
-        page_skeleton = None
-        if 'layout' in page.keys():
-            with codecs.open(opj(project, page['layout']), 'r', opts.input_enc) as fp:
-                page_skeleton = fp.read()
+        if 'template' in page:
+            fname = opj(project, page['template'])
+            with codecs.open(fname, 'r', opts.input_enc) as fp:
+                template = fp.read()
+        else:
+            template = default_template
 
         print("info   : render %s" % page.url)
 
         # replace expressions and statements in page.html
         macros["page"] = page
         macros["__content__"] = page.html
-
-        if page_skeleton is not None:
-            out = regx_eval.sub(repl_eval, page_skeleton)
-        else:
-            out = regx_eval.sub(repl_eval, skeleton)
-
+        out = regx_eval.sub(repl_eval, template)
         out = regx_exec.sub(repl_exec, out)
 
         # un-escape escaped python code blocks