Some more JSON outputting functions
This commit is contained in:
parent
ace4238915
commit
ca3c5b098d
@ -5,6 +5,8 @@ module Yesod.Json
|
|||||||
( -- * Monad
|
( -- * Monad
|
||||||
Json
|
Json
|
||||||
, jsonToContent
|
, jsonToContent
|
||||||
|
, jsonToRepJson
|
||||||
|
, htmlContentToText -- FIXME put elsewhere?
|
||||||
-- * Generate Json output
|
-- * Generate Json output
|
||||||
, jsonScalar
|
, jsonScalar
|
||||||
, jsonList
|
, jsonList
|
||||||
@ -50,6 +52,10 @@ newtype Json url a = Json { unJson :: Hamlet url IO a }
|
|||||||
jsonToContent :: Json (Routes master) () -> GHandler sub master Content
|
jsonToContent :: Json (Routes master) () -> GHandler sub master Content
|
||||||
jsonToContent = hamletToContent . unJson
|
jsonToContent = hamletToContent . unJson
|
||||||
|
|
||||||
|
-- | Wraps the 'Content' generated by 'jsonToContent' in a 'RepJson'.
|
||||||
|
jsonToRepJson :: Json (Routes master) () -> GHandler sub master RepJson
|
||||||
|
jsonToRepJson = fmap RepJson . jsonToContent
|
||||||
|
|
||||||
htmlContentToText :: HtmlContent -> Text
|
htmlContentToText :: HtmlContent -> Text
|
||||||
htmlContentToText (Encoded t) = t
|
htmlContentToText (Encoded t) = t
|
||||||
htmlContentToText (Unencoded t) = encodeHtml t
|
htmlContentToText (Unencoded t) = encodeHtml t
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user