module Shakebook.Mustache (
Text.Mustache.Template
, buildPageAction
, buildPageActionWithin
, compileTemplate'
) where
import Data.Aeson
import Development.Shake.Plus
import RIO
import qualified Slick.Mustache
import Text.Mustache
compileTemplate' :: MonadAction m => Path Rel File -> m Template
compileTemplate' = liftAction . Slick.Mustache.compileTemplate' . toFilePath
buildPageAction :: MonadAction m
=> Path Rel File
-> Value
-> Path Rel File
-> m ()
buildPageAction template value out = do
pageT <- compileTemplate' template
writeFile' out $ substitute pageT value
buildPageActionWithin :: MonadAction m
=> Within Rel (Path Rel File)
-> Value
-> Within Rel (Path Rel File)
-> m ()
buildPageActionWithin template value out = buildPageAction (fromWithin template) value (fromWithin out)