yesod-core-1.2.19: Creation of type-safe, RESTful web applications.

Safe HaskellNone

Yesod.Core.Widget

Contents

Description

Widgets combine HTML with JS and CSS dependencies with a unique identifier generator, allowing you to create truly modular HTML components.

Synopsis

Datatype

data WidgetT site m a Source

A generic widget, allowing specification of both the subsite and master site datatypes. While this is simply a WriterT, we define a newtype for better error messages.

Instances

MonadBaseControl b m => MonadBaseControl b (WidgetT site m) 
MonadBase b m => MonadBase b (WidgetT site m) 
Monad m => MonadReader site (WidgetT site m) 
(~ * site' site, ~ (* -> *) IO m, ~ * a ()) => ToWidget site' (WidgetT site m a) 
MonadTrans (WidgetT site) 
Monad m => Monad (WidgetT site m) 
Monad m => Functor (WidgetT site m) 
Monad m => Applicative (WidgetT site m) 
MonadActive m => MonadActive (WidgetT site m) 
MonadThrow m => MonadThrow (WidgetT site m) 
MonadCatch m => MonadCatch (WidgetT site m) 
MonadMask m => MonadMask (WidgetT site m) 
MonadIO m => MonadLogger (WidgetT site m) 
MonadIO m => MonadIO (WidgetT site m) 
(Applicative m, MonadIO m, MonadBase IO m, MonadThrow m) => MonadResource (WidgetT site m) 
MonadResourceBase m => MonadWidget (WidgetT site m) 
MonadResourceBase m => MonadHandler (WidgetT site m) 
(~ * a (), Monad m) => Monoid (WidgetT site m a) 

data PageContent url Source

Content for a web page. By providing this datatype, we can easily create generic site templates, which would have the type signature:

 PageContent url -> HtmlUrl url

Constructors

PageContent 

Fields

pageTitle :: Html
 
pageHead :: HtmlUrl url
 
pageBody :: HtmlUrl url
 

Special Hamlet quasiquoter/TH for Widgets

ihamletToRepHtml :: (MonadHandler m, RenderMessage (HandlerSite m) message) => HtmlUrlI18n message (Route (HandlerSite m)) -> m HtmlSource

Deprecated: Please use ihamletToHtml instead

Wraps the Content generated by hamletToContent in a RepHtml.

ihamletToHtml :: (MonadHandler m, RenderMessage (HandlerSite m) message) => HtmlUrlI18n message (Route (HandlerSite m)) -> m HtmlSource

Wraps the Content generated by hamletToContent in a RepHtml.

Since 1.2.1

Convert to Widget

class ToWidget site a whereSource

Methods

toWidget :: (MonadWidget m, HandlerSite m ~ site) => a -> m ()Source

Instances

ToWidget site Html 
ToWidget site Javascript 
ToWidget site CssBuilder 
ToWidget site Css 
~ * render (RY site) => ToWidget site (render -> Javascript) 
~ * render (RY site) => ToWidget site (render -> CssBuilder) 
~ * render (RY site) => ToWidget site (render -> Css) 
~ * render (RY site) => ToWidget site (render -> Html) 
(~ * site' site, ~ (* -> *) IO m, ~ * a ()) => ToWidget site' (WidgetT site m a) 

class ToWidgetHead site a whereSource

Methods

toWidgetHead :: (MonadWidget m, HandlerSite m ~ site) => a -> m ()Source

Instances

ToWidgetHead site Html 
ToWidgetHead site Javascript 
ToWidgetHead site CssBuilder 
ToWidgetHead site Css 
~ * render (RY site) => ToWidgetHead site (render -> Javascript) 
~ * render (RY site) => ToWidgetHead site (render -> CssBuilder) 
~ * render (RY site) => ToWidgetHead site (render -> Css) 
~ * render (RY site) => ToWidgetHead site (render -> Html) 

class ToWidgetBody site a whereSource

Methods

toWidgetBody :: (MonadWidget m, HandlerSite m ~ site) => a -> m ()Source

Instances

ToWidgetBody site Html 
ToWidgetBody site Javascript 
~ * render (RY site) => ToWidgetBody site (render -> Javascript) 
~ * render (RY site) => ToWidgetBody site (render -> Html) 

class ToWidgetMedia site a whereSource

Allows adding some CSS to the page with a specific media type.

Since 1.2

Methods

toWidgetMediaSource

Arguments

:: (MonadWidget m, HandlerSite m ~ site) 
=> Text

media value

-> a 
-> m () 

Add the given content to the page, but only for the given media type.

Since 1.2

Instances

ToWidgetMedia site CssBuilder 
ToWidgetMedia site Css 
~ * render (RY site) => ToWidgetMedia site (render -> CssBuilder) 
~ * render (RY site) => ToWidgetMedia site (render -> Css) 

Creating

Head of page

setTitle :: MonadWidget m => Html -> m ()Source

Set the page title. Calling setTitle multiple times overrides previously set values.

setTitleI :: (MonadWidget m, RenderMessage (HandlerSite m) msg) => msg -> m ()Source

Set the page title. Calling setTitle multiple times overrides previously set values.

CSS

addStylesheet :: MonadWidget m => Route (HandlerSite m) -> m ()Source

Link to the specified local stylesheet.

addStylesheetAttrs :: MonadWidget m => Route (HandlerSite m) -> [(Text, Text)] -> m ()Source

Link to the specified local stylesheet.

addStylesheetRemote :: MonadWidget m => Text -> m ()Source

Link to the specified remote stylesheet.

addStylesheetRemoteAttrs :: MonadWidget m => Text -> [(Text, Text)] -> m ()Source

Link to the specified remote stylesheet.

newtype CssBuilder Source

Newtype wrapper allowing injection of arbitrary content into CSS.

Usage:

 toWidget $ CssBuilder "p { color: red }"

Since: 1.1.3

Constructors

CssBuilder 

Instances

ToWidgetHead site CssBuilder 
ToWidgetMedia site CssBuilder 
ToWidget site CssBuilder 
~ * render (RY site) => ToWidgetHead site (render -> CssBuilder) 
~ * render (RY site) => ToWidgetMedia site (render -> CssBuilder) 
~ * render (RY site) => ToWidget site (render -> CssBuilder) 

Javascript

addScript :: MonadWidget m => Route (HandlerSite m) -> m ()Source

Link to the specified local script.

addScriptAttrs :: MonadWidget m => Route (HandlerSite m) -> [(Text, Text)] -> m ()Source

Link to the specified local script.

addScriptRemote :: MonadWidget m => Text -> m ()Source

Link to the specified remote script.

addScriptRemoteAttrs :: MonadWidget m => Text -> [(Text, Text)] -> m ()Source

Link to the specified remote script.

Subsites

widgetToParentWidget :: MonadIO m => WidgetT child IO a -> HandlerT child (HandlerT parent m) (WidgetT parent m a)Source

handlerToWidget :: Monad m => HandlerT site m a -> WidgetT site m aSource

Internal

asWidgetT :: WidgetT site m () -> WidgetT site m ()Source