on master help sign in
Added getValue function.
58ad6a9Jasper Van der Jeugt
src/Text/Hakyll/Page.hs+6
@@ -1,6 +1,7 @@
1module Text.Hakyll.Page
1module Text.Hakyll.Page
2 ( Page,
2 ( Page,
3 fromContext,
3 fromContext,
4+ getValue,
4 copyValueWith,
5 copyValueWith,
5 getBody,
6 getBody,
6 readPage,
7 readPage,
@@ -29,6 +30,11 @@ data Page = Page (M.Map B.ByteString B.ByteString)
29fromContext :: (M.Map B.ByteString B.ByteString) -> Page
30fromContext :: (M.Map B.ByteString B.ByteString) -> Page
30fromContext = Page
31fromContext = Page
31
32
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+
32-- | Do something with a value of the page.
38-- | Do something with a value of the page.
33copyValueWith :: String -- ^ Key of which the value should be copied.
39copyValueWith :: String -- ^ Key of which the value should be copied.
34 -> String -- ^ Key the value should be copied to.
40 -> String -- ^ Key the value should be copied to.