🐙 Templated web page generator for your git repositories
git clone https://github.com/m-col/gitja
Files | Refs | Readme | License

Commit 55a9c26b5349a0f6c95c224de3be7b9b88faa273
Parent: e696f1824408c0cfe30703c7aee1985e978698fb
Author: mcol <mcol@posteo.net>
Date: 2021-09-25 12:11:27 +0100
Committer: mcol <mcol@posteo.net>
Committed: 2021-09-25 12:11:27 +0100

Clear contents of target files if they exist

src/Templates.hs Modified

@@ -103,6 +103,7 @@
     -> HashMap.HashMap Text (GVal (Run SourcePos IO Html))
     -> Template
     -> IO (Either (RuntimeError SourcePos) (GVal (Run SourcePos IO Html)))
-generate output context template = easyRenderM writeToPath context (templateGinger template)
-  where
-    writeToPath = writeTo $ output </> (takeFileName . templatePath $ template)
+generate output context template = do
+    let target = (</>) output . takeFileName . templatePath $ template
+    writeFile target ""  -- Clear contents of file if it exists
+    easyRenderM (writeTo target) context . templateGinger $ template