ihp-1.4.0: Haskell Web Framework
Safe HaskellNone
LanguageGHC2021

IHP.Controller.Render

Synopsis

Documentation

renderPlain :: (?request :: Request) => LByteString -> IO () Source #

respondHtml :: (?request :: Request) => Html -> IO () Source #

respondSvg :: (?request :: Request) => Html -> IO () Source #

renderHtml :: (View view, ?context :: ControllerContext, ?request :: Request) => view -> IO Html Source #

renderFile :: (?request :: Request) => String -> ByteString -> IO () Source #

renderJson :: (?request :: Request, ToJSON json) => json -> IO () Source #

renderJsonWithStatusCode :: (?request :: Request, ToJSON json) => Status -> json -> IO () Source #

renderXml :: (?request :: Request) => LByteString -> IO () Source #

renderJson' :: (?request :: Request) => ResponseHeaders -> ToJSON json => json -> IO () Source #

Use setHeader instead

data PolymorphicRender Source #

Constructors

PolymorphicRender 

Fields

renderPolymorphic :: (?context :: ControllerContext, ?request :: Request) => 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 :: (View view, ?context :: ControllerContext, ?request :: Request, ?respond :: Respond) => view -> IO () Source #