@@ -87,14 +87,18 @@ applyTemplate' tpl context x = go tpl
87 context' = unContext (context `mappend` missingField)
87 context' = unContext (context `mappend` missingField)
88 go = liftM concat . mapM applyElem . unTemplate
88 go = liftM concat . mapM applyElem . unTemplate
90− applyElem (Chunk c) = return c
90+ applyElem (Chunk c) = return c
91− applyElem Escaped = return "$"
92+ applyElem Escaped = return "$"
92− applyElem (Key k) = context' k x >>= getString k
94+ applyElem (Key k) = context' k x >>= getString k
93 applyElem (If k t mf) = (context' k x >> go t) `catchError` handler
96 applyElem (If k t mf) = (context' k x >> go t) `catchError` handler
95 handler _ = case mf of
98 handler _ = case mf of
96 Nothing -> return ""
99 Nothing -> return ""
97 Just f -> go f
100 Just f -> go f
98 applyElem (For k b s) = context' k x >>= \cf -> case cf of
102 applyElem (For k b s) = context' k x >>= \cf -> case cf of
99 StringField _ -> fail $
103 StringField _ -> fail $
100 "Hakyll.Web.Template.applyTemplateWith: expected ListField but " ++
104 "Hakyll.Web.Template.applyTemplateWith: expected ListField but " ++
@@ -104,6 +108,10 @@ applyTemplate' tpl context x = go tpl
104 bs <- mapM (applyTemplate' b c) xs
108 bs <- mapM (applyTemplate' b c) xs
105 return $ intercalate sep bs
109 return $ intercalate sep bs
111+ applyElem (Partial p) = do
112+ tpl' <- loadBody (fromFilePath p)
113+ applyTemplate' tpl' context x
107 getString _ (StringField s) = return s
115 getString _ (StringField s) = return s
108 getString k (ListField _ _) = fail $
116 getString k (ListField _ _) = fail $
109 "Hakyll.Web.Template.applyTemplateWith: expected StringField but " ++
117 "Hakyll.Web.Template.applyTemplateWith: expected StringField but " ++