summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll/Internal
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-06-20 10:45:17 +0200
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-06-20 10:45:17 +0200
commitbb9ea6f1226b55a584cfcec47efeddabc230418d (patch)
tree74924cc1a3b8172906c64b50a3320f9014422cfd /src/Text/Hakyll/Internal
parent2282e78e9c9a6fd0919a13a11e070ac52cdce52f (diff)
downloadhakyll-bb9ea6f1226b55a584cfcec47efeddabc230418d.tar.gz
Add newtype for Context
Diffstat (limited to 'src/Text/Hakyll/Internal')
-rw-r--r--src/Text/Hakyll/Internal/Page.hs4
-rw-r--r--src/Text/Hakyll/Internal/Template.hs7
2 files changed, 6 insertions, 5 deletions
diff --git a/src/Text/Hakyll/Internal/Page.hs b/src/Text/Hakyll/Internal/Page.hs
index e2998a5..59bae65 100644
--- a/src/Text/Hakyll/Internal/Page.hs
+++ b/src/Text/Hakyll/Internal/Page.hs
@@ -12,7 +12,7 @@ import Control.Monad.State (State, evalState, get, put)
import Text.Pandoc
-import Text.Hakyll.Context (Context)
+import Text.Hakyll.Context (Context (..))
import Text.Hakyll.File
import Text.Hakyll.HakyllMonad
import Text.Hakyll.Regex (substituteRegex, matchesRegex)
@@ -103,7 +103,7 @@ readPageFromFile path = do
context = M.fromList $
("url", url) : ("path", path) : category ++ sectionsData
- return context
+ return $ Context context
where
category = let dirs = splitDirectories $ takeDirectory path
in [("category", last dirs) | not (null dirs)]
diff --git a/src/Text/Hakyll/Internal/Template.hs b/src/Text/Hakyll/Internal/Template.hs
index b7d1db0..bd8db2c 100644
--- a/src/Text/Hakyll/Internal/Template.hs
+++ b/src/Text/Hakyll/Internal/Template.hs
@@ -7,6 +7,7 @@ module Text.Hakyll.Internal.Template
, finalSubstitute
) where
+import Control.Applicative ((<$>))
import Data.List (isPrefixOf)
import Data.Char (isAlphaNum)
import Data.Binary
@@ -15,7 +16,7 @@ import Data.Maybe (fromMaybe)
import System.FilePath ((</>))
import qualified Data.Map as M
-import Text.Hakyll.Context (Context)
+import Text.Hakyll.Context (Context (..))
import Text.Hakyll.HakyllMonad (Hakyll)
import Text.Hakyll.Internal.Cache
import Text.Hakyll.Internal.Page
@@ -47,7 +48,7 @@ readTemplate path = do
if isCacheMoreRecent'
then getFromCache fileName
else do
- page <- readPage path
+ page <- unContext <$> readPage path
let body = fromMaybe (error $ "No body in template " ++ fileName)
(M.lookup "body" page)
template = fromString body
@@ -65,7 +66,7 @@ substitute escaper (Chunk chunk template) context =
substitute escaper (Identifier key template) context =
replacement ++ substitute escaper template context
where
- replacement = fromMaybe ('$' : key) $ M.lookup key context
+ replacement = fromMaybe ('$' : key) $ M.lookup key $ unContext context
substitute escaper (EscapeCharacter template) context =
escaper ++ substitute escaper template context
substitute _ End _ = []