summaryrefslogtreecommitdiff
path: root/src/Hakyll/Web/Blaze.hs
blob: e83b3406b21e8be9aac9c063ccd29d32944e1b05 (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
-- | 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