module Text.Blaze
(
Markup
, Tag
, Attribute
, AttributeValue
, dataAttribute
, customAttribute
, ToMarkup (..)
, text
, preEscapedText
, lazyText
, preEscapedLazyText
, string
, preEscapedString
, unsafeByteString
, unsafeLazyByteString
, textComment
, lazyTextComment
, stringComment
, unsafeByteStringComment
, unsafeLazyByteStringComment
, textTag
, stringTag
, ToValue (..)
, textValue
, preEscapedTextValue
, lazyTextValue
, preEscapedLazyTextValue
, stringValue
, preEscapedStringValue
, unsafeByteStringValue
, unsafeLazyByteStringValue
, (!)
, (!?)
, contents
) where
import Data.Int (Int32, Int64)
import Data.Monoid (mconcat)
import Data.Word (Word, Word32, Word64)
#if MIN_VERSION_base(4,8,0)
import Numeric.Natural (Natural)
#endif
import Data.Text (Text)
import qualified Data.Text.Lazy as LT
import qualified Data.Text.Lazy.Builder as LTB
import Text.Blaze.Internal
class ToMarkup a where
toMarkup :: a -> Markup
preEscapedToMarkup :: a -> Markup
preEscapedToMarkup = toMarkup
instance ToMarkup Markup where
toMarkup = id
instance ToMarkup [Markup] where
toMarkup = mconcat
instance ToMarkup Text where
toMarkup = text
preEscapedToMarkup = preEscapedText
instance ToMarkup LT.Text where
toMarkup = lazyText
preEscapedToMarkup = preEscapedLazyText
instance ToMarkup LTB.Builder where
toMarkup = textBuilder
preEscapedToMarkup = preEscapedTextBuilder
instance ToMarkup String where
toMarkup = string
preEscapedToMarkup = preEscapedString
instance ToMarkup Int where
toMarkup = string . show
instance ToMarkup Int32 where
toMarkup = string . show
instance ToMarkup Int64 where
toMarkup = string . show
#if MIN_VERSION_base(4,8,0)
instance ToMarkup Natural where
toMarkup = string . show
#endif
instance ToMarkup Char where
toMarkup = string . return
instance ToMarkup Bool where
toMarkup = string . show
instance ToMarkup Integer where
toMarkup = string . show
instance ToMarkup Float where
toMarkup = string . show
instance ToMarkup Double where
toMarkup = string . show
instance ToMarkup Word where
toMarkup = string . show
instance ToMarkup Word32 where
toMarkup = string . show
instance ToMarkup Word64 where
toMarkup = string . show
class ToValue a where
toValue :: a -> AttributeValue
preEscapedToValue :: a -> AttributeValue
preEscapedToValue = toValue
instance ToValue AttributeValue where
toValue = id
instance ToValue Text where
toValue = textValue
preEscapedToValue = preEscapedTextValue
instance ToValue LT.Text where
toValue = lazyTextValue
preEscapedToValue = preEscapedLazyTextValue
instance ToValue LTB.Builder where
toValue = textBuilderValue
preEscapedToValue = preEscapedTextBuilderValue
instance ToValue String where
toValue = stringValue
preEscapedToValue = preEscapedStringValue
instance ToValue Int where
toValue = stringValue . show
instance ToValue Int32 where
toValue = stringValue . show
instance ToValue Int64 where
toValue = stringValue . show
instance ToValue Char where
toValue = stringValue . return
instance ToValue Bool where
toValue = stringValue . show
instance ToValue Integer where
toValue = stringValue . show
instance ToValue Float where
toValue = stringValue . show
instance ToValue Double where
toValue = stringValue . show
instance ToValue Word where
toValue = stringValue . show
instance ToValue Word32 where
toValue = stringValue . show
instance ToValue Word64 where
toValue = stringValue . show