From 2eb81abb648d497b8b9e497ec00d58a893f3727e Mon Sep 17 00:00:00 2001 From: Starfall Date: Sat, 23 Oct 2021 12:47:20 -0500 Subject: strike: statement of intent for a few more variables --- README | 10 ++++++++-- strike.py | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README b/README index f8aefaa..93fac3e 100644 --- a/README +++ b/README @@ -24,7 +24,7 @@ And some stretch goals to turn it into a blog generator: strike.ini file --------------- -Strike should be passed the location of a .ini file or a directory containing a file named strike.ini. This is a text file in Python's configparser format (for now). You can see an example config file in the sample directory. +Strike should be passed the location of a .ini file or a directory containing a file named strike.ini. This is a text file in Python's configparser format (for now). You can see an example config file with all supported options at sample/strike.ini. Markup ------ @@ -36,7 +36,13 @@ It generates
s and has specific markup for page titles. Templating ---------- -TBD. Right now, templates should be written in plain HTML. The special marker ${content} will be replaced with all custom page content (also in raw HTML). +TBD. + +Right now, templates are just HTML in a Python f-string. You have access to the following variables: + +{content} : Complete file contents. +{meta['title']} : Filename, with extension dropped. +{meta['date']} : File modification date. Front matter ------------ diff --git a/strike.py b/strike.py index b6d526b..f3ae173 100755 --- a/strike.py +++ b/strike.py @@ -39,14 +39,14 @@ def main(): except FileExistsError: pass with open(default_template) as t: - template_contents = t.read() + template = t.read() for file in listdir(input_dir): if file in exclusions: continue with open(path.join(input_dir, file), 'r') as fin: file_contents = fin.read() - output = get_output(file_contents, template=template_contents) + output = get_output(file_contents, template) with open(path.join(output_dir, file), 'w') as fout: fout.write(output) -- cgit