@@ -13,9 +13,11 @@ import Test.Tasty.HUnit (Assertion, testCase, (@=?))
13--------------------------------------------------------------------------------
13--------------------------------------------------------------------------------
14import Hakyll.Core.Compiler
14import Hakyll.Core.Compiler
15import Hakyll.Core.Identifier
15import Hakyll.Core.Identifier
16+import Hakyll.Core.Item
16import Hakyll.Core.Provider
17import Hakyll.Core.Provider
17import Hakyll.Core.Store (Store)
18import Hakyll.Core.Store (Store)
18import Hakyll.Web.Template.Context
19import Hakyll.Web.Template.Context
20+import Hakyll.Web.Template.Internal
19import TestSuite.Util
21import TestSuite.Util
@@ -23,6 +25,7 @@ import TestSuite.Util
23tests :: TestTree
25tests :: TestTree
24tests = testGroup "Hakyll.Web.Template.Context.Tests"
26tests = testGroup "Hakyll.Web.Template.Context.Tests"
25 [ testCase "testDateField" testDateField
27 [ testCase "testDateField" testDateField
28+ , testCase "testOuerLoopContextAccess" testOuerLoopContextAccess
@@ -65,3 +68,28 @@ testContextDone store provider identifier key context =
65 _ -> error $
68 _ -> error $
66 "Hakyll.Web.Template.Context.Tests.testContextDone: " ++
69 "Hakyll.Web.Template.Context.Tests.testContextDone: " ++
67 "expected StringField"
70 "expected StringField"
72+--------------------------------------------------------------------------------
74+testOuerLoopContextAccess :: Assertion
75+testOuerLoopContextAccess = do
76+ store <- newTestStore
77+ provider <- newTestProvider store
78+ test store provider ctx "baz"
79+ test store provider (ctx' <> ctx) "not baz"
80+ test store provider (ctx <> ctx') "baz"
84+ tpl = readTemplate "$for(foo)$$for(bar)$$qux$$endfor$$endfor$"
86+ field "qux" $ const $ return "baz"
87+ , listField "foo" (listField "bar" mempty $ return [mockItem])
90+ ctx' = field "qux" $ const $ return "not baz"
91+ mockItem = Item "" ()
92+ test store provider context str = do
93+ str' <- testCompilerDone store provider ""
94+ $ applyTemplate tpl context mockItem
95+ str @=? itemBody str'