packages feed

Spock-lucid 0.1.0.0 → 0.2.0.0

raw patch · 3 files changed

+32/−6 lines, 3 filesdep +blaze-builderPVP ok

version bump matches the API change (PVP)

Dependencies added: blaze-builder

API changes (from Hackage documentation)

+ Web.Spock.Lucid: lucidIO :: MonadIO m => HtmlT IO a -> ActionCtxT cxt m a
- Web.Spock.Lucid: lucid :: MonadIO m => HtmlT m a -> ActionCtxT ctx m a
+ Web.Spock.Lucid: lucid :: MonadIO m => Html a -> ActionCtxT cxt m a

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@-# 0.1.0.0+# 0.2.0.0++* Change types (the previous version was unusable).+* Actually return the value returned by the Lucid action.++# 0.1.0.0 (deprecated)  First release.
Spock-lucid.cabal view
@@ -1,5 +1,5 @@ name:                Spock-lucid-version:             0.1.0.0+version:             0.2.0.0 synopsis:            Lucid support for Spock description:   Lucid support for Spock@@ -26,6 +26,7 @@   -- other-extensions:       build-depends:       Spock >= 0.9                      , base >= 4.7 && < 4.10+                     , blaze-builder                      , lucid == 2.*                      , transformers   ghc-options:         -Wall -fno-warn-unused-do-bind
lib/Web/Spock/Lucid.hs view
@@ -1,24 +1,44 @@ {-# LANGUAGE-OverloadedStrings+CPP,+OverloadedStrings,+RankNTypes   #-}   module Web.Spock.Lucid (   lucid,+  lucidIO, ) where  -import Control.Monad.Trans.Class+import Data.Functor.Identity import Control.Monad.IO.Class import Web.Spock import Lucid.Base+import Blaze.ByteString.Builder +#if !MIN_VERSION_base(4,8,0)+import Data.Monoid (mempty)+#endif + -- | Render HTML and send as response body. Content-type will be @text/html@.-lucid :: MonadIO m => HtmlT m a -> ActionCtxT ctx m a+lucid :: MonadIO m => Html a -> ActionCtxT cxt m a lucid x = do   setHeader "Content-Type" "text/html; charset=utf-8"-  lazyBytes =<< lift (renderBST x)+  let Identity (render, a) = runHtmlT x+  lazyBytes (toLazyByteString (render mempty))+  return a {-# INLINE lucid #-}++-- | Like 'lucid', but for @HtmlT IO@.+lucidIO :: MonadIO m => HtmlT IO a -> ActionCtxT cxt m a+lucidIO x = do+  setHeader "Content-Type" "text/html; charset=utf-8"+  (render, a) <- liftIO (runHtmlT x)+  lazyBytes (toLazyByteString (render mempty))+  return a+{-# INLINE lucidIO #-}+