on master help sign in
Fix partials and add a test

Fixes #460

commitfdb298d6a22dbab32d5da6c653b600d1b8f93143 authorJasper Van der Jeugt <m@jaspervdj.be> dateThu 4 Aug 2016, 14:13 (10 years ago) parent82ba954
5 files changed+28−2
src/Hakyll/Web/Template/Internal.hs+2−2 tests/Hakyll/Core/Runtime/Tests.hs+13 tests/data/partial-helper.html+3 tests/data/partial.html+3 tests/data/partial.html.out+7
src/Hakyll/Web/Template/Internal.hs+2−2
@@ -138,8 +138,8 @@ applyTemplate' tes context x = go tes
138138 return $ intercalate sep bs
139139
140140 applyElem (Partial e) = do
141− p <- applyExpr e >>= getString e
142− tpl' <- loadBody (fromFilePath p)
141+ p <- applyExpr e >>= getString e
142+ Template tpl' <- loadBody (fromFilePath p)
143143 applyTemplate' tpl' context x
144144
145145 ---------------------------------------------------------------------------
tests/Hakyll/Core/Runtime/Tests.hs+13
@@ -41,6 +41,15 @@ case01 = do
4141 >>= saveSnapshot "raw"
4242 >>= renderPandoc
4343
44+ match (fromList ["partial.html", "partial-helper.html"]) $
45+ compile templateCompiler
46+ create ["partial.html.out"] $ do
47+ route idRoute
48+ compile $ do
49+ example <- loadSnapshotBody "example.md" "raw"
50+ makeItem example
51+ >>= loadAndApplyTemplate "partial.html" defaultContext
52+
4453 create ["bodies.txt"] $ do
4554 route idRoute
4655 compile $ do
@@ -60,6 +69,10 @@ case01 = do
6069 bodies <- readFile $ destinationDirectory testConfiguration </> "bodies.txt"
6170 head (lines bodies) @?= "This is an example."
6271
72+ partial <- readFile $ providerDirectory testConfiguration </> "partial.html.out"
73+ partial' <- readFile $ destinationDirectory testConfiguration </> "partial.html.out"
74+ partial @?= partial'
75+
6376 cleanTestEnv
6477
6578
tests/data/partial-helper.htmlnew file+3
@@ -0,0 +1,3 @@
1+<p>This is an included partial.</p>
2+
3+$body$
tests/data/partial.htmlnew file+3
@@ -0,0 +1,3 @@
1+<p>This is a file that includes a partial.</p>
2+
3+$partial("partial-helper.html")$
tests/data/partial.html.outnew file+7
@@ -0,0 +1,7 @@
1+<p>This is a file that includes a partial.</p>
2+
3+<p>This is an included partial.</p>
4+
5+This is an example.
6+
7+