diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2016-08-04 14:13:24 +0200 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2016-08-04 14:13:24 +0200 |
commit | fdb298d6a22dbab32d5da6c653b600d1b8f93143 (patch) | |
tree | c7f335d08d00bf02e01e139102f0c0458f07682a | |
parent | 82ba9542e75238f4b69d1a497d429962cdff1e14 (diff) | |
download | hakyll-fdb298d6a22dbab32d5da6c653b600d1b8f93143.tar.gz |
Fix partials and add a test
Fixes #460
-rw-r--r-- | src/Hakyll/Web/Template/Internal.hs | 4 | ||||
-rw-r--r-- | tests/Hakyll/Core/Runtime/Tests.hs | 13 | ||||
-rw-r--r-- | tests/data/partial-helper.html | 3 | ||||
-rw-r--r-- | tests/data/partial.html | 3 | ||||
-rw-r--r-- | tests/data/partial.html.out | 7 |
5 files changed, 28 insertions, 2 deletions
diff --git a/src/Hakyll/Web/Template/Internal.hs b/src/Hakyll/Web/Template/Internal.hs index 3686914..d0e4d47 100644 --- a/src/Hakyll/Web/Template/Internal.hs +++ b/src/Hakyll/Web/Template/Internal.hs @@ -138,8 +138,8 @@ applyTemplate' tes context x = go tes return $ intercalate sep bs applyElem (Partial e) = do - p <- applyExpr e >>= getString e - tpl' <- loadBody (fromFilePath p) + p <- applyExpr e >>= getString e + Template tpl' <- loadBody (fromFilePath p) applyTemplate' tpl' context x --------------------------------------------------------------------------- diff --git a/tests/Hakyll/Core/Runtime/Tests.hs b/tests/Hakyll/Core/Runtime/Tests.hs index 1ef77ca..1bdfc60 100644 --- a/tests/Hakyll/Core/Runtime/Tests.hs +++ b/tests/Hakyll/Core/Runtime/Tests.hs @@ -41,6 +41,15 @@ case01 = do >>= saveSnapshot "raw" >>= renderPandoc + match (fromList ["partial.html", "partial-helper.html"]) $ + compile templateCompiler + create ["partial.html.out"] $ do + route idRoute + compile $ do + example <- loadSnapshotBody "example.md" "raw" + makeItem example + >>= loadAndApplyTemplate "partial.html" defaultContext + create ["bodies.txt"] $ do route idRoute compile $ do @@ -60,6 +69,10 @@ case01 = do bodies <- readFile $ destinationDirectory testConfiguration </> "bodies.txt" head (lines bodies) @?= "This is an example." + partial <- readFile $ providerDirectory testConfiguration </> "partial.html.out" + partial' <- readFile $ destinationDirectory testConfiguration </> "partial.html.out" + partial @?= partial' + cleanTestEnv diff --git a/tests/data/partial-helper.html b/tests/data/partial-helper.html new file mode 100644 index 0000000..15c86ba --- /dev/null +++ b/tests/data/partial-helper.html @@ -0,0 +1,3 @@ +<p>This is an included partial.</p> + +$body$ diff --git a/tests/data/partial.html b/tests/data/partial.html new file mode 100644 index 0000000..b4d81bb --- /dev/null +++ b/tests/data/partial.html @@ -0,0 +1,3 @@ +<p>This is a file that includes a partial.</p> + +$partial("partial-helper.html")$ diff --git a/tests/data/partial.html.out b/tests/data/partial.html.out new file mode 100644 index 0000000..19f7ed7 --- /dev/null +++ b/tests/data/partial.html.out @@ -0,0 +1,7 @@ +<p>This is a file that includes a partial.</p> + +<p>This is an included partial.</p> + +This is an example. + + |