summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2009-12-25 23:49:15 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2009-12-25 23:49:15 +0100
commit58ad6a9d38bc74152128f52a9636d6e5e20c1b93 (patch)
treefbc213b5b43420a1617a41f56aae51df8e9f5aaf /src/Text/Hakyll
parent637ab61284802c033372787d9af938282b8f69c5 (diff)
downloadhakyll-58ad6a9d38bc74152128f52a9636d6e5e20c1b93.tar.gz
Added getValue function.
Diffstat (limited to 'src/Text/Hakyll')
-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.