summaryrefslogtreecommitdiff
path: root/src/Hakyll/Web/Blaze.hs
blob: 8a22585dee663c878dbe29f8839ad4ed7cc0d40a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
-- | Module providing BlazeHtml support for hakyll
--
module Hakyll.Web.Blaze
    ( getFieldHtml
    , getFieldHtml'
    , getBodyHtml
    , getBodyHtml'
    ) where

import Text.Blaze.Html (Html, toHtml)
import Text.Blaze.Internal (preEscapedString)

import Hakyll.Web.Page
import Hakyll.Web.Page.Metadata

-- | Get a field from a page and convert it to HTML. This version does not
-- 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