diff --git a/byg/src/DependencyGenerator.hs b/byg/src/DependencyGenerator.hs index 0a6f4d8..4adc8db 100644 --- a/byg/src/DependencyGenerator.hs +++ b/byg/src/DependencyGenerator.hs @@ -228,8 +228,11 @@ listDirectory a = runFunctionIO ListDirectory =<< toToken a isDirectory :: TokenableTo FilePath a => a -> DepGenM' Bool isDirectory a = runFunctionIO IsDirectory =<< toToken a -readTemplate :: TokenableTo FilePath a => a -> DepGenM' Template -readTemplate a = runFunctionIO ReadTemplate =<< toToken a +readTemplate :: (TokenableTo FilePath a, TokenableTo Text b) => a -> b -> DepGenM' Template +readTemplate a b = do + a' <- toToken a + b' <- toToken b + runFunctionIO ReadTemplate $ TupleToken (a', b') convertImage :: (TokenableTo (FilePath, FilePath) a, TokenableTo ImageConversionSettings b) => a -> b -> DepGenM () convertImage a b = do diff --git a/byg/src/Evaluation/FunctionIO.hs b/byg/src/Evaluation/FunctionIO.hs index c478c96..b56a9ce 100644 --- a/byg/src/Evaluation/FunctionIO.hs +++ b/byg/src/Evaluation/FunctionIO.hs @@ -24,10 +24,9 @@ evalFunctionIO f x = case (f, x) of (IsDirectory, String (StringWrapper s)) -> Bool <$> doesDirectoryExist s - (ReadTemplate, String (StringWrapper s)) -> do + (ReadTemplate, Tuple (String (StringWrapper s), Text c)) -> do t <- T.readFile s - let c = "CONTENT" - (beforeContent, after) = T.breakOn c t + let (beforeContent, after) = T.breakOn c t afterContent = T.drop (T.length c) after pure $ Template $ TemplateParts beforeContent afterContent @@ -62,4 +61,4 @@ evalFunctionIO f x = case (f, x) of pure $ Text $ TL.toStrict $ B.renderHtml html _ -> - error "unexpected combination of function and argument type" + error ("unexpected combination of function and argument type; got function " ++ show f ++ " with argument " ++ show x) diff --git a/byg/src/SiteGenerator.hs b/byg/src/SiteGenerator.hs index 6edd2bd..258b828 100644 --- a/byg/src/SiteGenerator.hs +++ b/byg/src/SiteGenerator.hs @@ -62,7 +62,7 @@ generateSite = do recipesDir <- inject "retter" outputRecipesDir <- joinPaths outputDir recipesDir makeDir outputRecipesDir - template <- readTemplate $ inject "template.html" + template <- readTemplate (inject "template.html") (inject "CONTENT") indexName <- inject "index.html" dirNames <- listDirectory recipesDir dirPaths <- mapDepGenM (joinPaths recipesDir) dirNames