packages feed

blaze-html 0.3.2.1 → 0.4.0.0

raw patch · 4 files changed

+110/−30 lines, 4 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

- Text.Blaze: preEscapedShowHtml :: Show a => a -> Html
- Text.Blaze: showHtml :: Show a => a -> Html
- Text.Blaze.Internal: preEscapedShowHtml :: Show a => a -> Html
- Text.Blaze.Internal: showHtml :: Show a => a -> Html
+ Text.Blaze: class ToHtml a
+ Text.Blaze: class ToValue a
+ Text.Blaze: instance ToHtml Bool
+ Text.Blaze: instance ToHtml Char
+ Text.Blaze: instance ToHtml Double
+ Text.Blaze: instance ToHtml Float
+ Text.Blaze: instance ToHtml Html
+ Text.Blaze: instance ToHtml Int
+ Text.Blaze: instance ToHtml Integer
+ Text.Blaze: instance ToHtml String
+ Text.Blaze: instance ToHtml Text
+ Text.Blaze: instance ToValue AttributeValue
+ Text.Blaze: instance ToValue Bool
+ Text.Blaze: instance ToValue Char
+ Text.Blaze: instance ToValue Double
+ Text.Blaze: instance ToValue Float
+ Text.Blaze: instance ToValue Int
+ Text.Blaze: instance ToValue Integer
+ Text.Blaze: instance ToValue String
+ Text.Blaze: instance ToValue Text
+ Text.Blaze: toHtml :: ToHtml a => a -> Html
+ Text.Blaze: toValue :: ToValue a => a -> AttributeValue

Files

Text/Blaze.hs view
@@ -1,5 +1,4 @@-{-# LANGUAGE OverloadedStrings, GeneralizedNewtypeDeriving, Rank2Types,-             FlexibleInstances #-}+{-# LANGUAGE TypeSynonymInstances #-} -- | BlazeHtml is an HTML combinator library. It provides a way to embed HTML in -- Haskell in an efficient and convenient way, with a light-weight syntax. --@@ -45,14 +44,13 @@     , customAttribute        -- * Converting values to HTML.+    , ToHtml (..)     , text     , preEscapedText     , lazyText     , preEscapedLazyText     , string     , preEscapedString-    , showHtml-    , preEscapedShowHtml     , unsafeByteString        -- * Creating tags.@@ -60,6 +58,7 @@     , stringTag        -- * Converting values to attribute values.+    , ToValue (..)     , textValue     , preEscapedTextValue     , lazyTextValue@@ -72,4 +71,104 @@     , (!)     ) where +import Data.Text (Text)+import qualified Data.Text.Lazy as LT+ import Text.Blaze.Internal++-- | Class allowing us to use a single function for HTML values+--+class ToHtml a where+    -- | Convert a value to HTML.+    --+    toHtml :: a -> Html+    {-# INLINE toHtml #-}++instance ToHtml Html where+    toHtml = id+    {-# INLINE toHtml #-}++instance ToHtml Text where+    toHtml = text+    {-# INLINE toHtml #-}++instance ToHtml LT.Text where+    toHtml = lazyText+    {-# INLINE toHtml #-}++instance ToHtml String where+    toHtml = string+    {-# INLINE toHtml #-}++instance ToHtml Int where+    toHtml = string . show+    {-# INLINE toHtml #-}++instance ToHtml Char where+    toHtml = string . return+    {-# INLINE toHtml #-}++instance ToHtml Bool where+    toHtml = string . show+    {-# INLINE toHtml #-}++instance ToHtml Integer where+    toHtml = string . show+    {-# INLINE toHtml #-}++instance ToHtml Float where+    toHtml = string . show+    {-# INLINE toHtml #-}++instance ToHtml Double where+    toHtml = string . show+    {-# INLINE toHtml #-}+++-- | Class allowing us to use a single function for attribute values+--+class ToValue a where+    -- | Convert a value to an HTML attribute value+    --+    toValue :: a -> AttributeValue+    {-# INLINE toValue #-}++instance ToValue AttributeValue where+    toValue = id+    {-# INLINE toValue #-}++instance ToValue Text where+    toValue = textValue+    {-# INLINE toValue #-}++instance ToValue LT.Text where+    toValue = lazyTextValue+    {-# INLINE toValue #-}++instance ToValue String where+    toValue = stringValue+    {-# INLINE toValue #-}++instance ToValue Int where+    toValue = stringValue . show+    {-# INLINE toValue #-}++instance ToValue Char where+    toValue = stringValue . return+    {-# INLINE toValue #-}++instance ToValue Bool where+    toValue = stringValue . show+    {-# INLINE toValue #-}++instance ToValue Integer where+    toValue = stringValue . show+    {-# INLINE toValue #-}++instance ToValue Float where+    toValue = stringValue . show+    {-# INLINE toValue #-}++instance ToValue Double where+    toValue = stringValue . show+    {-# INLINE toValue #-}
Text/Blaze/Internal.hs view
@@ -30,8 +30,6 @@     , preEscapedLazyText     , string     , preEscapedString-    , showHtml-    , preEscapedShowHtml     , unsafeByteString        -- * Converting values to tags.@@ -260,23 +258,6 @@                  -> Html    -- ^ Resulting HTML fragment. preEscapedString = Content . PreEscaped . String {-# INLINE preEscapedString #-}---- | Create an HTML snippet from a datatype that instantiates 'Show'.----showHtml :: Show a-         => a       -- ^ Value to insert.-         -> Html    -- ^ Resulting HTML fragment.-showHtml = string . show-{-# INLINE showHtml #-}---- | Create an HTML snippet from a datatype that instantiates 'Show'. This--- function will not do any HTML entity escaping.----preEscapedShowHtml :: Show a-                   => a     -- ^ Value to insert.-                   -> Html  -- ^ Resulting HTML fragment.-preEscapedShowHtml = preEscapedString . show-{-# INLINE preEscapedShowHtml #-}  -- | Insert a 'ByteString'. This is an unsafe operation: --
Text/Blaze/Renderer/String.hs view
@@ -22,12 +22,12 @@                    -> String  -- ^ Resulting string escapeHtmlEntities []     k = k escapeHtmlEntities (c:cs) k = case c of-    '<'  -> "&lt;"   ++ escapeHtmlEntities cs k-    '>'  -> "&gt;"   ++ escapeHtmlEntities cs k-    '&'  -> "&amp;"  ++ escapeHtmlEntities cs k-    '"'  -> "&quot;" ++ escapeHtmlEntities cs k-    '\'' -> "&#39;"  ++ escapeHtmlEntities cs k-    x    -> x : escapeHtmlEntities cs k+    '<'  -> '&' : 'l' : 't' : ';'             : escapeHtmlEntities cs k+    '>'  -> '&' : 'g' : 't' : ';'             : escapeHtmlEntities cs k+    '&'  -> '&' : 'a' : 'm' : 'p' : ';'       : escapeHtmlEntities cs k+    '"'  -> '&' : 'q' : 'u' : 'o' : 't' : ';' : escapeHtmlEntities cs k+    '\'' -> '&' : '#' : '3' : '9' : ';'       : escapeHtmlEntities cs k+    x    -> x                                 : escapeHtmlEntities cs k  -- | Render a 'ChoiceString'. --
blaze-html.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version:             0.3.2.1+Version:             0.4.0.0  -- A short (one-line) description of the package. Synopsis:            A blazingly fast HTML combinator library.