Added getValue function.
This commit is contained in:
parent
637ab61284
commit
58ad6a9d38
1 changed files with 6 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
module Text.Hakyll.Page
|
||||
( Page,
|
||||
fromContext,
|
||||
getValue,
|
||||
copyValueWith,
|
||||
getBody,
|
||||
readPage,
|
||||
|
@ -29,6 +30,11 @@ data Page = Page (M.Map B.ByteString B.ByteString)
|
|||
fromContext :: (M.Map B.ByteString B.ByteString) -> 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.
|
||||
copyValueWith :: String -- ^ Key of which the value should be copied.
|
||||
-> String -- ^ Key the value should be copied to.
|
||||
|
|
Loading…
Reference in a new issue