diff options
Diffstat (limited to 'src/Text/Hakyll/Internal')
| -rw-r--r-- | src/Text/Hakyll/Internal/Page.hs | 4 | ||||
| -rw-r--r-- | src/Text/Hakyll/Internal/Template.hs | 7 |
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 _ = [] |
