BlazeHtml 0.1

This commit is contained in:
Michael Snoyman 2010-06-20 10:34:14 +03:00
parent 72aad8659d
commit bc7fc91606
5 changed files with 9 additions and 9 deletions

View File

@ -24,7 +24,7 @@ import Web.Routes.Quasi (Routes)
-- --
-- > PageContent url -> Hamlet url -- > PageContent url -> Hamlet url
data PageContent url = PageContent data PageContent url = PageContent
{ pageTitle :: Html { pageTitle :: Html ()
, pageHead :: Hamlet url , pageHead :: Hamlet url
, pageBody :: Hamlet url , pageBody :: Hamlet url
} }

View File

@ -306,14 +306,14 @@ msgKey = "_MSG"
-- | Sets a message in the user's session. -- | Sets a message in the user's session.
-- --
-- See 'getMessage'. -- See 'getMessage'.
setMessage :: Html -> GHandler sub master () setMessage :: Html () -> GHandler sub master ()
setMessage = setSession msgKey . L.toString . renderHtml setMessage = setSession msgKey . L.toString . renderHtml
-- | Gets the message in the user's session, if available, and then clears the -- | Gets the message in the user's session, if available, and then clears the
-- variable. -- variable.
-- --
-- See 'setMessage'. -- See 'setMessage'.
getMessage :: GHandler sub master (Maybe Html) getMessage :: GHandler sub master (Maybe (Html ()))
getMessage = do getMessage = do
clearSession msgKey clearSession msgKey
fmap (fmap preEscapedString) $ lookupSession msgKey fmap (fmap preEscapedString) $ lookupSession msgKey

View File

@ -44,10 +44,10 @@ data AtomFeedEntry url = AtomFeedEntry
{ atomEntryLink :: url { atomEntryLink :: url
, atomEntryUpdated :: UTCTime , atomEntryUpdated :: UTCTime
, atomEntryTitle :: String , atomEntryTitle :: String
, atomEntryContent :: Html , atomEntryContent :: Html ()
} }
xmlns :: AtomFeed url -> Html xmlns :: AtomFeed url -> Html ()
xmlns _ = preEscapedString "http://www.w3.org/2005/Atom" xmlns _ = preEscapedString "http://www.w3.org/2005/Atom"
template :: AtomFeed url -> Hamlet url template :: AtomFeed url -> Hamlet url

View File

@ -50,7 +50,7 @@ data SitemapUrl url = SitemapUrl
, priority :: Double , priority :: Double
} }
sitemapNS :: Html sitemapNS :: Html ()
sitemapNS = string "http://www.sitemaps.org/schemas/sitemap/0.9" sitemapNS = string "http://www.sitemaps.org/schemas/sitemap/0.9"
template :: [SitemapUrl url] -> Hamlet url template :: [SitemapUrl url] -> Hamlet url

View File

@ -41,7 +41,7 @@ import Yesod.Content
-- This is an opaque type to avoid any possible insertion of non-JSON content. -- This is an opaque type to avoid any possible insertion of non-JSON content.
-- Due to the limited nature of the JSON format, you can create any valid JSON -- Due to the limited nature of the JSON format, you can create any valid JSON
-- document you wish using only 'jsonScalar', 'jsonList' and 'jsonMap'. -- document you wish using only 'jsonScalar', 'jsonList' and 'jsonMap'.
newtype Json = Json { unJson :: Html } newtype Json = Json { unJson :: Html () }
deriving Monoid deriving Monoid
-- | Extract the final result from the given 'Json' value. -- | Extract the final result from the given 'Json' value.
@ -61,10 +61,10 @@ jsonToRepJson = fmap RepJson . jsonToContent
-- * Performs JSON encoding. -- * Performs JSON encoding.
-- --
-- * Wraps the resulting string in quotes. -- * Wraps the resulting string in quotes.
jsonScalar :: Html -> Json jsonScalar :: Html () -> Json
jsonScalar s = Json $ mconcat jsonScalar s = Json $ mconcat
[ preEscapedString "\"" [ preEscapedString "\""
, unsafeBytestring $ S.concat $ L.toChunks $ encodeJson $ renderHtml s , unsafeByteString $ S.concat $ L.toChunks $ encodeJson $ renderHtml s
, preEscapedString "\"" , preEscapedString "\""
] ]
where where