parent
82ba9542e7
commit
fdb298d6a2
5 changed files with 28 additions and 2 deletions
|
@ -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
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
3
tests/data/partial-helper.html
Normal file
3
tests/data/partial-helper.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
<p>This is an included partial.</p>
|
||||
|
||||
$body$
|
3
tests/data/partial.html
Normal file
3
tests/data/partial.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
<p>This is a file that includes a partial.</p>
|
||||
|
||||
$partial("partial-helper.html")$
|
7
tests/data/partial.html.out
Normal file
7
tests/data/partial.html.out
Normal file
|
@ -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.
|
||||
|
||||
|
Loading…
Reference in a new issue