about summary refs log tree commit diff
path: root/strike.py
diff options
context:
space:
mode:
Diffstat (limited to 'strike.py')
-rwxr-xr-xstrike.py25
1 files changed, 11 insertions, 14 deletions
diff --git a/strike.py b/strike.py
index 3ca1e19..e3e5e52 100755
--- a/strike.py
+++ b/strike.py
@@ -1,29 +1,26 @@
 #!/usr/bin/env python3
 from os import listdir, mkdir
 from sys import exit
-from inspect import cleandoc
 
-def get_output(content):
-    return cleandoc(f'''
-    i am a template
-    with some stuff,
-    {content},
-    and some more stuff
-    ''')
+def get_output(content, template="{content}"):
+    return template.format(content = content)
 
 def main():
     src = 'blog'
     dest = 'output'
+    template = 'template'
 
     try: mkdir(dest)
     except FileExistsError: pass
 
-    for file in listdir(src):
-        with open(src + '/' + file, 'r') as fin:
-            file_contents = fin.read()
-            output = get_output(file_contents)
-            with open(dest + '/' + file, 'w') as fout:
-                fout.write(output)
+    with open(template) as t:
+        template_contents = t.read()
+        for file in listdir(src):
+            with open(src + '/' + file, 'r') as fin:
+                file_contents = fin.read()
+                output = get_output(file_contents, template=template_contents)
+                with open(dest + '/' + file, 'w') as fout:
+                    fout.write(output)
 
 if __name__ == '__main__':
     exit(main())