summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Text/Hakyll/Page.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/Text/Hakyll/Page.hs b/src/Text/Hakyll/Page.hs
index 0415755..cecb686 100644
--- a/src/Text/Hakyll/Page.hs
+++ b/src/Text/Hakyll/Page.hs
@@ -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.