Safe Haskell | Safe-Inferred |
---|
IHP.Controller.Render
Synopsis
- renderPlain :: (?context :: ControllerContext) => LByteString -> IO ()
- respondHtml :: (?context :: ControllerContext) => Html -> IO ()
- respondSvg :: (?context :: ControllerContext) => Html -> IO ()
- renderHtml :: forall view. (View view, ?context :: ControllerContext) => view -> IO Html
- renderFile :: (?context :: ControllerContext) => String -> ByteString -> IO ()
- renderJson :: (?context :: ControllerContext) => ToJSON json => json -> IO ()
- renderJsonWithStatusCode :: (?context :: ControllerContext) => ToJSON json => Status -> json -> IO ()
- renderXml :: (?context :: ControllerContext) => LByteString -> IO ()
- renderJson' :: (?context :: ControllerContext) => ResponseHeaders -> ToJSON json => json -> IO ()
- renderNotFound :: (?context :: ControllerContext) => IO ()
- data PolymorphicRender = PolymorphicRender {}
- renderPolymorphic :: (?context :: ControllerContext) => PolymorphicRender -> IO ()
- polymorphicRender :: PolymorphicRender
- render :: forall view. (View view, ?context :: ControllerContext) => view -> IO ()
Documentation
renderPlain :: (?context :: ControllerContext) => LByteString -> IO () Source #
respondHtml :: (?context :: ControllerContext) => Html -> IO () Source #
respondSvg :: (?context :: ControllerContext) => Html -> IO () Source #
renderHtml :: forall view. (View view, ?context :: ControllerContext) => view -> IO Html Source #
renderFile :: (?context :: ControllerContext) => String -> ByteString -> IO () Source #
renderJson :: (?context :: ControllerContext) => ToJSON json => json -> IO () Source #
renderJsonWithStatusCode :: (?context :: ControllerContext) => ToJSON json => Status -> json -> IO () Source #
renderXml :: (?context :: ControllerContext) => LByteString -> IO () Source #
renderJson' :: (?context :: ControllerContext) => ResponseHeaders -> ToJSON json => json -> IO () Source #
Use setHeader
intead
renderNotFound :: (?context :: ControllerContext) => IO () Source #
Render's a generic not found page
This can be useful e.g. when an entity cannot be found:
action ExampleAction = do renderNotFound
You can override the default not found error page by creating a new file at static/404.html
. Then IHP will render that HTML file instead of displaying the default IHP not found page.
data PolymorphicRender Source #
renderPolymorphic :: (?context :: ControllerContext) => PolymorphicRender -> IO () Source #
Can be used to render different responses for html, json, etc. requests based on Accept
header
Example:
show :: Action show = do renderPolymorphic polymorphicRender { html = renderHtml [hsx|<div>Hello World</div>|] json = renderJson True }
This will render Hello World
for normal browser requests and true
when requested via an ajax request