{-# LANGUAGE OverloadedStrings #-}
module Text.Blaze.Tests.Util
( renderUsingString
, renderUsingText
, renderUsingUtf8
, p, div, table, img, br, area
, id, class_, name
) where
import Prelude hiding (div, id)
import Text.Blaze.Internal
import Blaze.ByteString.Builder as B (toLazyByteString)
import Blaze.ByteString.Builder.Char.Utf8 as B (fromString)
import Data.Text.Lazy.Encoding (encodeUtf8)
import qualified Data.ByteString.Lazy as LB
import qualified Text.Blaze.Renderer.String as String (renderMarkup)
import qualified Text.Blaze.Renderer.Text as Text (renderMarkup)
import qualified Text.Blaze.Renderer.Utf8 as Utf8 (renderMarkup)
renderUsingString :: Markup -> LB.ByteString
renderUsingString = toLazyByteString . fromString . String.renderMarkup
renderUsingText :: Markup -> LB.ByteString
renderUsingText = encodeUtf8 . Text.renderMarkup
renderUsingUtf8 :: Markup -> LB.ByteString
renderUsingUtf8 = Utf8.renderMarkup
p :: Markup
-> Markup
p = Parent "p" "<p" "</p>"
div :: Markup
-> Markup
div = Parent "div" "<div" "</div>"
table :: Markup
-> Markup
table = Parent "table" "<table" "</table>"
img :: Markup
img = Leaf "img" "<img" ">"
br :: Markup
br = Leaf "br" "<br" ">"
area :: Markup
area = Leaf "area" "<area" ">"
class_ :: AttributeValue
-> Attribute
class_ = attribute "class" " class=\""
id :: AttributeValue
-> Attribute
id = attribute "id" " id=\""
name :: AttributeValue
-> Attribute
name = attribute "name" " name=\""