From 58ad6a9d38bc74152128f52a9636d6e5e20c1b93 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Fri, 25 Dec 2009 23:49:15 +0100 Subject: Added getValue function. --- src/Text/Hakyll/Page.hs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') 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. -- cgit v1.2.3