summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll/Internal
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-03-10 19:47:53 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-03-10 19:47:53 +0100
commit35e824648499d868b2c37b41ecc8f847f452917b (patch)
treeafe1194fc88249b2a0a04714bda051fa21170002 /src/Text/Hakyll/Internal
parent23f9d1e0cfb82260b73ce8799756fa6d3a838a70 (diff)
downloadhakyll-35e824648499d868b2c37b41ecc8f847f452917b.tar.gz
Merged Text.Hakyll.Internal.Render into Text.Hakyll.Render.
Diffstat (limited to 'src/Text/Hakyll/Internal')
-rw-r--r--src/Text/Hakyll/Internal/Render.hs39
1 files changed, 0 insertions, 39 deletions
diff --git a/src/Text/Hakyll/Internal/Render.hs b/src/Text/Hakyll/Internal/Render.hs
deleted file mode 100644
index a771556..0000000
--- a/src/Text/Hakyll/Internal/Render.hs
+++ /dev/null
@@ -1,39 +0,0 @@
--- | Internal module do some low-level rendering.
-module Text.Hakyll.Internal.Render
- ( pureRender
- , writePage
- ) where
-
-import qualified Data.Map as M
-import Control.Monad.Reader (liftIO)
-import Data.Maybe (fromMaybe)
-
-import Text.Hakyll.File
-import Text.Hakyll.Hakyll
-import Text.Hakyll.HakyllAction
-import Text.Hakyll.Internal.Template
-
--- | A pure render function.
-pureRender :: Template -- ^ Template to use for rendering.
- -> Context -- ^ Renderable object to render with given template.
- -> Context -- ^ The body of the result will contain the render.
-pureRender template context =
- -- Ignore $root when substituting here. We will only replace that in the
- -- final render (just before writing).
- let contextIgnoringRoot = M.insert "root" "$root" context
- body = regularSubstitute template contextIgnoringRoot
- in M.insert "body" body context
-
--- | Write a page to the site destination. Final action after render
--- chains and such.
-writePage :: HakyllAction Context ()
-writePage = createHakyllAction $ \initialContext -> do
- additionalContext' <- askHakyll getAdditionalContext
- let url = fromMaybe (error "No url defined at write time.")
- (M.lookup "url" initialContext)
- body = fromMaybe "" (M.lookup "body" initialContext)
- let context = additionalContext' `M.union` M.singleton "root" (toRoot url)
- destination <- toDestination url
- makeDirectories destination
- -- Substitute $root here, just before writing.
- liftIO $ writeFile destination $ finalSubstitute (fromString body) context