summaryrefslogtreecommitdiff
path: root/src/Hakyll/Web/Blaze.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Hakyll/Web/Blaze.hs')
-rw-r--r--src/Hakyll/Web/Blaze.hs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/Hakyll/Web/Blaze.hs b/src/Hakyll/Web/Blaze.hs
new file mode 100644
index 0000000..e83b340
--- /dev/null
+++ b/src/Hakyll/Web/Blaze.hs
@@ -0,0 +1,34 @@
+-- | Module providing BlazeHtml support for hakyll
+--
+module Hakyll.Web.Blaze
+ ( getFieldHtml
+ , getFieldHtml'
+ , getBodyHtml
+ , getBodyHtml'
+ ) where
+
+import Text.Blaze (Html, toHtml, preEscapedString)
+
+import Hakyll.Web.Page
+import Hakyll.Web.Page.Metadata
+
+-- | Get a field from a page and convert it to HTML. This version does escape
+-- the given HTML
+--
+getFieldHtml :: String -> Page a -> Html
+getFieldHtml key = preEscapedString . getField key
+
+-- | Version of 'getFieldHtml' that escapes the HTML content
+--
+getFieldHtml' :: String -> Page a -> Html
+getFieldHtml' key = toHtml . getField key
+
+-- | Get the body as HTML
+--
+getBodyHtml :: Page String -> Html
+getBodyHtml = preEscapedString . pageBody
+
+-- | Version of 'getBodyHtml' that escapes the HTML content
+--
+getBodyHtml' :: Page String -> Html
+getBodyHtml' = toHtml . pageBody