Added basic template functionality.
[cmless] / bin / template.py
diff --git a/bin/template.py b/bin/template.py
new file mode 100644 (file)
index 0000000..c5b1d19
--- /dev/null
@@ -0,0 +1,21 @@
+# (c) 2017 Aaron Taylor <ataylor at subgeniuskitty dot com>
+# See LICENSE file for copyright and license details.
+
+# Python imports
+import os
+
+# CMless imports
+import config, misc
+
+def tpl_title(template):
+    keyword = "page_title"
+    return template.replace(config.template_delimiter + keyword +
+            config.template_delimiter, os.environ['REQUEST_URI'])
+
+def tpl_body(template):
+    keyword = "page_content"
+    body = misc.load_file(config.site_data_prefix + os.environ['REQUEST_URI'] +
+            config.markup_file_extension)
+    body = misc.process_markup(body)
+    return template.replace(config.template_delimiter + keyword +
+            config.template_delimiter, body)