{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
module Lib.Templating where
import Uniform.Http
import Uniform.Json ( Value, ErrIO )
import Uniform.PandocHTMLwriter ( applyTemplate4 )
import UniformBase
putValinMaster :: NoticeLevel -> [Value] -> Path Abs File -> ErrIO HTMLout
putValinMaster :: NoticeLevel -> [Value] -> Path Abs File -> ErrIO HTMLout
putValinMaster NoticeLevel
debug [Value]
vals Path Abs File
masterfn = do
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (NoticeLevel -> Bool
inform NoticeLevel
debug) forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). MonadIO m => [Text] -> m ()
putIOwords [Text
"putValinMaster", Text
"masterfn", forall {a}. Show a => a -> Text
showT Path Abs File
masterfn]
Text
template2 :: Text <- forall fp fc. FileOps2 fp fc => fp -> ErrIO fc
readFile2 (forall b t. Path b t -> FilePath
toFilePath Path Abs File
masterfn)
Text
html2 <- Bool -> Text -> [Value] -> ErrIO Text
applyTemplate4 (NoticeLevel -> Bool
inform NoticeLevel
debug) Text
template2 [Value]
vals
forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> HTMLout
HTMLout forall a b. (a -> b) -> a -> b
$ Text
html2