lucid 0.0 → 0.1
raw patch · 5 files changed
+30/−3 lines, 5 filesdep +mtl
Dependencies added: mtl
Files
- README.md +10/−0
- lucid.cabal +3/−1
- src/Lucid/Base.hs +13/−2
- src/Lucid/Bootstrap.hs +2/−0
- src/Lucid/Html5.hs +2/−0
README.md view
@@ -115,3 +115,13 @@ See the documentation for the `Lucid` module for information about using it as a monad transformer.++## Transforming++You can use `lift` to call parent monads.++``` haskell+λ> runReader (renderTextT (html_ (body_ (do name <- lift ask; p_ (toHtml name)))))+ ("Chris" :: String)+"<html><body><p>Chris</p></body></html>"+```
lucid.cabal view
@@ -1,8 +1,9 @@ name: lucid-version: 0.0+version: 0.1 synopsis: Clear to write, read and edit DSL for HTML description: Clear to write, read and edit DSL for HTML. See the 'Lucid' module for description and documentation.+homepage: https://github.com/chrisdone/lucid license: BSD3 license-file: LICENSE author: Chris Done@@ -25,3 +26,4 @@ , bytestring , text , transformers+ , mtl
src/Lucid/Base.hs view
@@ -36,6 +36,7 @@ import qualified Blaze.ByteString.Builder.Html.Utf8 as Blaze import Control.Applicative import Control.Monad+import Control.Monad.Reader import Data.ByteString.Lazy (ByteString) import Data.Functor.Identity import Data.Monoid@@ -97,6 +98,16 @@ f' attr inner ,b)) +-- | Used for 'lift'.+instance MonadTrans HtmlT where+ lift m =+ HtmlT (do a <- m+ return (\_ _ -> mempty,a))++-- | If you want to use IO in your HTML generation.+instance MonadIO m => MonadIO (HtmlT m) where+ liftIO = lift . liftIO+ -- | We pack it via string. Could possibly encode straight into a -- builder. That might be faster. instance (Monad m,a ~ ()) => IsString (HtmlT m a) where@@ -125,8 +136,8 @@ -- | Can be converted to HTML. class ToHtml a where- toHtml :: a -> Html ()- toHtmlRaw :: a -> Html ()+ toHtml :: Monad m => a -> HtmlT m ()+ toHtmlRaw :: Monad m => a -> HtmlT m () instance ToHtml String where toHtml = fromString
src/Lucid/Bootstrap.hs view
@@ -1,3 +1,5 @@+{-# OPTIONS -fno-warn-type-defaults #-}+ -- | Bootstrap layout elements. See -- <http://getbootstrap.com/2.3.2/scaffolding.html> for more -- information.
src/Lucid/Html5.hs view
@@ -1,3 +1,5 @@+{-# OPTIONS -fno-warn-type-defaults #-}+ -- | Html5 terms. module Lucid.Html5 where