IHP Api Reference
Safe HaskellNone

IHP.Controller.Render

Synopsis

Documentation

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 #

Constructors

PolymorphicRender 

Fields

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

render :: forall view. (View view, ?context :: ControllerContext) => view -> IO () Source #