@@ -53,6 +53,7 @@ module Hakyll.Web.Template
5353import Control.Arrow
5454import Data.Maybe (fromMaybe)
5555import System.FilePath (takeExtension)
56+import qualified Data.Map as M
5657
5758import Text.Hamlet (HamletSettings, defaultHamletSettings)
5859
@@ -62,7 +63,6 @@ import Hakyll.Core.ResourceProvider
6263import Hakyll.Web.Template.Internal
6364import Hakyll.Web.Template.Read
6465import Hakyll.Web.Page.Internal
65−import Hakyll.Web.Page.Metadata
6666
6767-- | Substitutes @$identifiers@ in the given @Template@ by values from the given
6868-- "Page". When a key is not found, it is left as it is. You can specify
@@ -72,9 +72,9 @@ applyTemplate :: Template -> Page String -> Page String
7272applyTemplate template page =
7373 fmap (const $ substitute =<< unTemplate template) page
7474 where
75+ map' = toMap page
7576 substitute (Chunk chunk) = chunk
76− substitute (Key key) =
77− fromMaybe ("$" ++ key ++ "$") $ getFieldMaybe key page
77+ substitute (Key key) = fromMaybe ("$" ++ key ++ "$") $ M.lookup key map'
7878 substitute (Escaped) = "$"
7979
8080-- | Apply a page as it's own template. This is often very useful to fill in