on master help sign in
Added getValue function.
commit58ad6a9d38bc74152128f52a9636d6e5e20c1b93 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateFri 25 Dec 2009, 23:49 (17 years ago) parent637ab61
1 file changed+6
src/Text/Hakyll/Page.hs+6
src/Text/Hakyll/Page.hs+6
@@ -1,6 +1,7 @@
11module Text.Hakyll.Page
22 ( Page,
33 fromContext,
4+ getValue,
45 copyValueWith,
56 getBody,
67 readPage,
@@ -29,6 +30,11 @@ data Page = Page (M.Map B.ByteString B.ByteString)
2930fromContext :: (M.Map B.ByteString B.ByteString) -> Page
3031fromContext = Page
3132
33+-- | Obtain a value from a page. Will resturn an empty string when nothing is
34+-- found.
35+getValue :: String -> Page -> B.ByteString
36+getValue str (Page page) = fromMaybe B.empty $ M.lookup (B.pack str) page
37+
3238-- | Do something with a value of the page.
3339copyValueWith :: String -- ^ Key of which the value should be copied.
3440 -> String -- ^ Key the value should be copied to.