Commit 4c70db20972441bbfc282ce305f414e250a299ec Parent: a7b783c236e1820dd4a645d4e737d9d216164b19 Author: mcol <mcol@posteo.net> Date: 2021-09-30 00:58:38 +0100 Committer: mcol <mcol@posteo.net> Committed: 2021-09-30 01:05:06 +0100 Clean up template filtering
src/Templates.hs Modified
@@ -113,11 +113,12 @@ This is used to filter files in the template directory so that we only try to load HTML/CSS/JS files. -} -isTemplate :: FilePath -> IO Bool -isTemplate path = (&&) (isTemplate' (map toLower path)) <$> doesFileExist path +isTemplate :: Config -> FilePath -> IO Bool +isTemplate config path = (&&) (isTemplate' (map toLower path)) <$> doesFileExist path where isTemplate' :: FilePath -> Bool - isTemplate' p = isSuffixOf "html" p || isSuffixOf "css" p || isSuffixOf "js" p + isTemplate' p = + not (isScoped config p) && any id (flip isSuffixOf p <$> ["html", "css", "js"]) {- This is used to filter files in the template directory to exclude those specified by the @@ -141,8 +142,7 @@ valid template files. -} getFiles :: Config -> IO [FilePath] -getFiles config = - filter (isScoped config) <$> (filterM isTemplate <=< listTemplates . templateDirectory $ config) +getFiles config = (filterM (isTemplate config) <=< listTemplates . templateDirectory $ config) {- This function gets the output HTML data and is responsible for saving it to file.