Added getValue function.

This commit is contained in:
Jasper Van der Jeugt 2009-12-25 23:49:15 +01:00
parent 637ab61284
commit 58ad6a9d38

View file

@ -1,6 +1,7 @@
module Text.Hakyll.Page module Text.Hakyll.Page
( Page, ( Page,
fromContext, fromContext,
getValue,
copyValueWith, copyValueWith,
getBody, getBody,
readPage, readPage,
@ -29,6 +30,11 @@ data Page = Page (M.Map B.ByteString B.ByteString)
fromContext :: (M.Map B.ByteString B.ByteString) -> Page fromContext :: (M.Map B.ByteString B.ByteString) -> Page
fromContext = Page fromContext = Page
-- | Obtain a value from a page. Will resturn an empty string when nothing is
-- found.
getValue :: String -> Page -> B.ByteString
getValue str (Page page) = fromMaybe B.empty $ M.lookup (B.pack str) page
-- | Do something with a value of the page. -- | Do something with a value of the page.
copyValueWith :: String -- ^ Key of which the value should be copied. copyValueWith :: String -- ^ Key of which the value should be copied.
-> String -- ^ Key the value should be copied to. -> String -- ^ Key the value should be copied to.