aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Text/BlazeT/Renderer
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/BlazeT/Renderer')
-rw-r--r--src/Text/BlazeT/Renderer/Pretty.hs22
-rw-r--r--src/Text/BlazeT/Renderer/String.hs27
-rw-r--r--src/Text/BlazeT/Renderer/Text.hs75
-rw-r--r--src/Text/BlazeT/Renderer/Utf8.hs66
4 files changed, 190 insertions, 0 deletions
diff --git a/src/Text/BlazeT/Renderer/Pretty.hs b/src/Text/BlazeT/Renderer/Pretty.hs
new file mode 100644
index 0000000..8977c94
--- /dev/null
+++ b/src/Text/BlazeT/Renderer/Pretty.hs
@@ -0,0 +1,22 @@
1module Text.BlazeT.Renderer.Pretty
2 ( renderMarkup
3 , renderHtml
4 , renderMarkupT
5 , renderHtmlT
6 ) where
7
8import Control.Monad
9import Control.Monad.Identity
10import qualified Text.Blaze.Renderer.Pretty as BU
11import Text.BlazeT
12
13renderMarkup :: MarkupM a -> String
14renderMarkup = runIdentity . renderMarkupT
15renderMarkupT :: Monad m => MarkupT m a -> m String
16renderMarkupT = liftM BU.renderMarkup . execMarkupT
17
18renderHtml :: MarkupM a -> String
19renderHtml = renderMarkup
20renderHtmlT :: Monad m => MarkupT m a -> m String
21renderHtmlT = renderMarkupT
22
diff --git a/src/Text/BlazeT/Renderer/String.hs b/src/Text/BlazeT/Renderer/String.hs
new file mode 100644
index 0000000..0a2de8a
--- /dev/null
+++ b/src/Text/BlazeT/Renderer/String.hs
@@ -0,0 +1,27 @@
1module Text.BlazeT.Renderer.String
2 ( fromChoiceString
3 , renderMarkup
4 , renderHtml
5 , renderMarkupT
6 , renderHtmlT
7 ) where
8
9import Control.Monad
10import Control.Monad.Identity
11import Text.Blaze.Internal (ChoiceString)
12import qualified Text.Blaze.Renderer.String as BU
13import Text.BlazeT
14
15fromChoiceString :: ChoiceString -> String -> String
16fromChoiceString = BU.fromChoiceString
17
18renderMarkup :: MarkupM a -> String
19renderMarkup = runIdentity . renderMarkupT
20renderMarkupT :: Monad m => MarkupT m a -> m String
21renderMarkupT = liftM BU.renderMarkup . execMarkupT
22
23renderHtml :: MarkupM a -> String
24renderHtml = renderMarkup
25renderHtmlT :: Monad m => MarkupT m a -> m String
26renderHtmlT = renderMarkupT
27
diff --git a/src/Text/BlazeT/Renderer/Text.hs b/src/Text/BlazeT/Renderer/Text.hs
new file mode 100644
index 0000000..31181eb
--- /dev/null
+++ b/src/Text/BlazeT/Renderer/Text.hs
@@ -0,0 +1,75 @@
1module Text.BlazeT.Renderer.Text
2 ( renderMarkupBuilderT
3 , renderMarkupBuilder
4 , renderMarkupBuilderWithT
5 , renderMarkupT
6 , renderMarkupWithT
7 , renderHtmlBuilderT
8 , renderHtmlBuilderWithT
9 , renderHtmlT
10 , renderHtmlWithT
11 , renderMarkupBuilderWith
12 , renderMarkup
13 , renderMarkupWith
14 , renderHtmlBuilder
15 , renderHtmlBuilderWith
16 , renderHtml
17 , renderHtmlWith
18 ) where
19
20import Control.Monad
21import Data.ByteString (ByteString)
22import Control.Monad.Identity
23import Data.Text (Text)
24import qualified Data.Text.Lazy as L
25import qualified Data.Text.Lazy.Builder as B
26import qualified Text.Blaze.Html.Renderer.Text as BH
27import qualified Text.Blaze.Renderer.Text as BU
28import Text.BlazeT
29
30renderMarkupBuilder :: MarkupM a -> B.Builder
31renderMarkupBuilder = runIdentity . renderMarkupBuilderT
32
33renderMarkupBuilderT :: Monad m => MarkupT m a -> m B.Builder
34renderMarkupBuilderT = liftM BU.renderMarkupBuilder . execMarkupT
35
36renderHtmlBuilder :: MarkupM a -> B.Builder
37renderHtmlBuilder = renderMarkupBuilder
38
39renderHtmlBuilderT :: Monad m => MarkupT m a -> m B.Builder
40renderHtmlBuilderT = renderMarkupBuilderT
41
42renderMarkup :: MarkupM a -> L.Text
43renderMarkup = runIdentity . renderMarkupT
44renderMarkupT :: Monad m => MarkupT m a -> m L.Text
45renderMarkupT = liftM BU.renderMarkup . execMarkupT
46
47renderHtml :: MarkupM a -> L.Text
48renderHtml = renderMarkup
49renderHtmlT :: Monad m => MarkupT m a -> m L.Text
50renderHtmlT = renderMarkupT
51
52renderMarkupWithT :: Monad m => (ByteString -> Text) -> MarkupT m a -> m L.Text
53renderMarkupWithT g = liftM (BU.renderMarkupWith g) . execMarkupT
54
55renderMarkupWith :: (ByteString -> Text) -> MarkupM a -> L.Text
56renderMarkupWith g = runIdentity . renderMarkupWithT g
57
58renderHtmlWithT :: Monad m => (ByteString -> Text) -> MarkupT m a -> m L.Text
59renderHtmlWithT g = liftM (BH.renderHtmlWith g) . execMarkupT
60
61renderHtmlWith :: (ByteString -> Text) -> MarkupM a -> L.Text
62renderHtmlWith g = runIdentity . renderHtmlWithT g
63
64renderHtmlBuilderWithT :: Monad m => (ByteString -> Text) -> MarkupT m a -> m B.Builder
65renderHtmlBuilderWithT g = liftM (BH.renderHtmlBuilderWith g) . execMarkupT
66
67renderHtmlBuilderWith :: (ByteString -> Text) -> MarkupM a -> B.Builder
68renderHtmlBuilderWith g = runIdentity . renderHtmlBuilderWithT g
69
70
71renderMarkupBuilderWithT :: Monad m => (ByteString -> Text) -> MarkupT m a -> m B.Builder
72renderMarkupBuilderWithT g = liftM (BU.renderMarkupBuilderWith g) . execMarkupT
73
74renderMarkupBuilderWith :: (ByteString -> Text) -> MarkupM a -> B.Builder
75renderMarkupBuilderWith g = runIdentity . renderMarkupBuilderWithT g
diff --git a/src/Text/BlazeT/Renderer/Utf8.hs b/src/Text/BlazeT/Renderer/Utf8.hs
new file mode 100644
index 0000000..292f81f
--- /dev/null
+++ b/src/Text/BlazeT/Renderer/Utf8.hs
@@ -0,0 +1,66 @@
1{-# OPTIONS_GHC -fsimpl-tick-factor=230 #-}
2
3-- the above option was not needed with
4 -- ,blaze-html >= 0.6.0.0 && < 0.7.0.0
5 -- ,blaze-builder >= 0.2
6 -- ,text < 1.2
7
8module Text.BlazeT.Renderer.Utf8
9 (
10 renderMarkupBuilder
11 , renderMarkup
12 , renderMarkupToByteStringIO
13 , renderHtmlBuilder
14 , renderHtml
15 , renderHtmlToByteStringIO
16
17 -- * new BlazeT stuff
18 , renderMarkupBuilderT
19 , renderMarkupT
20 , renderMarkupToByteStringIOT
21 , renderHtmlToByteStringIOT
22 , renderHtmlBuilderT
23 , renderHtmlT
24 ) where
25
26import qualified Blaze.ByteString.Builder as B
27import Control.Monad
28import Control.Monad.Identity
29import qualified Data.ByteString as BS
30import qualified Data.ByteString.Lazy as BL
31import qualified Text.Blaze.Renderer.Utf8 as BU
32import Text.BlazeT
33
34renderMarkupBuilder :: MarkupM a -> B.Builder
35renderMarkupBuilder = runIdentity . renderMarkupBuilderT
36
37renderMarkupBuilderT :: Monad m => MarkupT m a -> m B.Builder
38renderMarkupBuilderT = liftM BU.renderMarkupBuilder . execMarkupT
39
40renderHtmlBuilder :: MarkupM a -> B.Builder
41renderHtmlBuilder = renderMarkupBuilder
42
43renderHtmlBuilderT :: Monad m => MarkupT m a -> m B.Builder
44renderHtmlBuilderT = renderMarkupBuilderT
45
46renderMarkup :: MarkupM a -> BL.ByteString
47renderMarkup = runIdentity . renderMarkupT
48renderMarkupT :: Monad m => MarkupT m a -> m BL.ByteString
49renderMarkupT = liftM BU.renderMarkup . execMarkupT
50
51renderHtml :: MarkupM a -> BL.ByteString
52renderHtml = renderMarkup
53renderHtmlT :: Monad m => MarkupT m a -> m BL.ByteString
54renderHtmlT = renderMarkupT
55
56renderMarkupToByteStringIO :: (BS.ByteString -> IO ()) -> MarkupM a -> IO ()
57renderMarkupToByteStringIO g = runIdentity . renderMarkupToByteStringIOT g
58renderMarkupToByteStringIOT :: Monad m => (BS.ByteString -> IO ()) ->
59 MarkupT m a -> m (IO ())
60renderMarkupToByteStringIOT g = liftM (BU.renderMarkupToByteStringIO g) . execMarkupT
61
62renderHtmlToByteStringIO :: (BS.ByteString -> IO ()) -> MarkupM a -> IO ()
63renderHtmlToByteStringIO g = runIdentity . renderMarkupToByteStringIOT g
64renderHtmlToByteStringIOT :: Monad m => (BS.ByteString -> IO ()) ->
65 MarkupT m a -> m (IO ())
66renderHtmlToByteStringIOT g = liftM (BU.renderMarkupToByteStringIO g) . execMarkupT