@@ -18,6 +18,7 @@ module Hakyll.Web.Template.Internal
1818
1919
2020--------------------------------------------------------------------------------
21+import Control.Applicative ((<|>))
2122import Control.Monad.Except (MonadError (..))
2223import Data.Binary (Binary)
2324import Data.List (intercalate)
@@ -134,8 +135,13 @@ applyTemplate' tes context x = go tes
134135 "got StringField for expr " ++ show e
135136 ListField c xs -> do
136137 sep <- maybe (return "") go s
137− bs <- mapM (applyTemplate' b c) xs
138+ bs <- mapM (applyTemplate' b $ combineContexts context x c) xs
138139 return $ intercalate sep bs
140+ where
141+ combineContexts :: Context a -> Item a -> Context b -> Context b
142+ combineContexts ca ia cb = Context $ \ k' args' ib' ->
143+ unContext cb k' args' ib'
144+ <|> unContext ca k' args' ia
139145
140146 applyElem (Partial e) = do
141147 p <- applyExpr e >>= getString e