on master help sign in
Simplified pureRenderAndConcat function.
d6fbe30Jasper Van der Jeugt
hakyll.cabal−1
@@ -34,7 +34,6 @@ library
34 mtl >= 1.1,
34 mtl >= 1.1,
35 old-locale >= 1,
35 old-locale >= 1,
36 time >= 1,
36 time >= 1,
37− deepseq >= 1,
38 binary >= 0.5
37 binary >= 0.5
39 exposed-modules: Text.Hakyll
38 exposed-modules: Text.Hakyll
40 Text.Hakyll.Hakyll
39 Text.Hakyll.Hakyll
src/Text/Hakyll/Render/Internal.hs+5−8
@@ -11,7 +11,6 @@ module Text.Hakyll.Render.Internal
11
11
12import qualified Data.Map as M
12import qualified Data.Map as M
13import Text.Hakyll.Context (Context, ContextManipulation)
13import Text.Hakyll.Context (Context, ContextManipulation)
14−import Control.DeepSeq (deepseq)
15import Control.Monad.Reader (liftIO)
14import Control.Monad.Reader (liftIO)
16import Data.List (isPrefixOf, foldl')
15import Data.List (isPrefixOf, foldl')
17import Data.Char (isAlphaNum)
16import Data.Char (isAlphaNum)
@@ -56,20 +55,18 @@ pureRenderWith manipulation template context =
56 -- final render (just before writing).
55 -- final render (just before writing).
57 let contextIgnoringRoot = M.insert "root" "$root" (manipulation context)
56 let contextIgnoringRoot = M.insert "root" "$root" (manipulation context)
58 body = regularSubstitute template contextIgnoringRoot
57 body = regularSubstitute template contextIgnoringRoot
59− -- Force the body to be rendered.
60− in body `deepseq` M.insert "body" body context
58+ in M.insert "body" body context
61
59
62-- | A pure renderAndConcat function.
60-- | A pure renderAndConcat function.
63pureRenderAndConcatWith :: ContextManipulation -- ^ Manipulation to apply.
61pureRenderAndConcatWith :: ContextManipulation -- ^ Manipulation to apply.
64 -> [String] -- ^ Templates to use.
62 -> [String] -- ^ Templates to use.
65 -> [Context] -- ^ Different renderables.
63 -> [Context] -- ^ Different renderables.
66 -> String
64 -> String
67−pureRenderAndConcatWith manipulation templates contexts =
65+pureRenderAndConcatWith manipulation templates =
68− foldl' renderAndConcat [] contexts
66+ concatMap renderAndConcat
69 where
67 where
70− renderAndConcat chunk context =
71− let rendered = pureRenderChainWith manipulation templates context
72− in chunk ++ fromMaybe "" (M.lookup "body" rendered)
68+ renderAndConcat = fromMaybe "" . M.lookup "body"
69+ . pureRenderChainWith manipulation templates
73
70
74-- | A pure renderChain function.
71-- | A pure renderChain function.
75pureRenderChainWith :: ContextManipulation
72pureRenderChainWith :: ContextManipulation