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
data PageContent url = PageContent
{ pageTitle :: Html
{ pageTitle :: Html ()
, pageHead :: Hamlet url
, pageBody :: Hamlet url
}

View File

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

View File

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

View File

@ -50,7 +50,7 @@ data SitemapUrl url = SitemapUrl
, priority :: Double
}
sitemapNS :: Html
sitemapNS :: Html ()
sitemapNS = string "http://www.sitemaps.org/schemas/sitemap/0.9"
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.
-- Due to the limited nature of the JSON format, you can create any valid JSON
-- document you wish using only 'jsonScalar', 'jsonList' and 'jsonMap'.
newtype Json = Json { unJson :: Html }
newtype Json = Json { unJson :: Html () }
deriving Monoid
-- | Extract the final result from the given 'Json' value.
@ -61,10 +61,10 @@ jsonToRepJson = fmap RepJson . jsonToContent
-- * Performs JSON encoding.
--
-- * Wraps the resulting string in quotes.
jsonScalar :: Html -> Json
jsonScalar :: Html () -> Json
jsonScalar s = Json $ mconcat
[ preEscapedString "\""
, unsafeBytestring $ S.concat $ L.toChunks $ encodeJson $ renderHtml s
, unsafeByteString $ S.concat $ L.toChunks $ encodeJson $ renderHtml s
, preEscapedString "\""
]
where