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

Safe HaskellNone
LanguageHaskell98

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) Source # 

Associated Types

type StM (WidgetT site m :: * -> *) a :: * #

Methods

liftBaseWith :: (RunInBase (WidgetT site m) b -> b a) -> WidgetT site m a #

restoreM :: StM (WidgetT site m) a -> WidgetT site m a #

MonadBase b m => MonadBase b (WidgetT site m) Source # 

Methods

liftBase :: b α -> WidgetT site m α #

Monad m => MonadReader site (WidgetT site m) Source # 

Methods

ask :: WidgetT site m site #

local :: (site -> site) -> WidgetT site m a -> WidgetT site m a #

reader :: (site -> a) -> WidgetT site m a #

((~) * site' site, (~) (* -> *) IO m, (~) * a ()) => ToWidget site' (WidgetT site m a) Source # 

Methods

toWidget :: (MonadWidget m, (* ~ HandlerSite m) site') => WidgetT site m a -> m () Source #

MonadTrans (WidgetT site) Source # 

Methods

lift :: Monad m => m a -> WidgetT site m a #

Monad m => Monad (WidgetT site m) Source # 

Methods

(>>=) :: WidgetT site m a -> (a -> WidgetT site m b) -> WidgetT site m b #

(>>) :: WidgetT site m a -> WidgetT site m b -> WidgetT site m b #

return :: a -> WidgetT site m a #

fail :: String -> WidgetT site m a #

Monad m => Functor (WidgetT site m) Source # 

Methods

fmap :: (a -> b) -> WidgetT site m a -> WidgetT site m b #

(<$) :: a -> WidgetT site m b -> WidgetT site m a #

Monad m => Applicative (WidgetT site m) Source # 

Methods

pure :: a -> WidgetT site m a #

(<*>) :: WidgetT site m (a -> b) -> WidgetT site m a -> WidgetT site m b #

(*>) :: WidgetT site m a -> WidgetT site m b -> WidgetT site m b #

(<*) :: WidgetT site m a -> WidgetT site m b -> WidgetT site m a #

MonadIO m => MonadIO (WidgetT site m) Source # 

Methods

liftIO :: IO a -> WidgetT site m a #

MonadActive m => MonadActive (WidgetT site m) Source # 

Methods

monadActive :: WidgetT site m Bool #

MonadThrow m => MonadThrow (WidgetT site m) Source # 

Methods

throwM :: Exception e => e -> WidgetT site m a #

MonadCatch m => MonadCatch (WidgetT site m) Source # 

Methods

catch :: Exception e => WidgetT site m a -> (e -> WidgetT site m a) -> WidgetT site m a #

MonadMask m => MonadMask (WidgetT site m) Source # 

Methods

mask :: ((forall a. WidgetT site m a -> WidgetT site m a) -> WidgetT site m b) -> WidgetT site m b #

uninterruptibleMask :: ((forall a. WidgetT site m a -> WidgetT site m a) -> WidgetT site m b) -> WidgetT site m b #

MonadIO m => MonadLogger (WidgetT site m) Source # 

Methods

monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> WidgetT site m () #

MonadIO m => MonadLoggerIO (WidgetT site m) Source # 

Methods

askLoggerIO :: WidgetT site m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #

(Applicative m, MonadIO m, MonadBase IO m, MonadThrow m) => MonadResource (WidgetT site m) Source # 

Methods

liftResourceT :: ResourceT IO a -> WidgetT site m a #

MonadResourceBase m => MonadWidget (WidgetT site m) Source # 

Methods

liftWidgetT :: WidgetT (HandlerSite (WidgetT site m)) IO a -> WidgetT site m a Source #

MonadResourceBase m => MonadHandler (WidgetT site m) Source # 

Associated Types

type HandlerSite (WidgetT site m :: * -> *) :: * Source #

Methods

liftHandlerT :: HandlerT (HandlerSite (WidgetT site m)) IO a -> WidgetT site m a Source #

(Monad m, (~) * a ()) => IsString (WidgetT site m a) Source #

A String can be trivially promoted to a widget.

For example, in a yesod-scaffold site you could use:

getHomeR = do defaultLayout "Widget text"

Methods

fromString :: String -> WidgetT site m a #

((~) * a (), Monad m) => Semigroup (WidgetT site m a) Source # 

Methods

(<>) :: WidgetT site m a -> WidgetT site m a -> WidgetT site m a #

sconcat :: NonEmpty (WidgetT site m a) -> WidgetT site m a #

stimes :: Integral b => b -> WidgetT site m a -> WidgetT site m a #

((~) * a (), Monad m) => Monoid (WidgetT site m a) Source # 

Methods

mempty :: WidgetT site m a #

mappend :: WidgetT site m a -> WidgetT site m a -> WidgetT site m a #

mconcat :: [WidgetT site m a] -> WidgetT site m a #

type HandlerSite (WidgetT site m) Source # 
type HandlerSite (WidgetT site m) = site
type StM (WidgetT site m) a Source # 
type StM (WidgetT site m) a = StM m (a, GWData (Route site))

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

Special Hamlet quasiquoter/TH for Widgets

ihamletToRepHtml :: (MonadHandler m, RenderMessage (HandlerSite m) message) => HtmlUrlI18n message (Route (HandlerSite m)) -> m Html Source #

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 Html Source #

Wraps the Content generated by hamletToContent in a RepHtml.

Since 1.2.1

Convert to Widget

class ToWidget site a where Source #

Minimal complete definition

toWidget

Methods

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

Instances

ToWidget site Html Source # 

Methods

toWidget :: (MonadWidget m, (* ~ HandlerSite m) site) => Html -> m () Source #

ToWidget site Javascript Source # 

Methods

toWidget :: (MonadWidget m, (* ~ HandlerSite m) site) => Javascript -> m () Source #

ToWidget site CssBuilder Source # 

Methods

toWidget :: (MonadWidget m, (* ~ HandlerSite m) site) => CssBuilder -> m () Source #

ToWidget site Css Source # 

Methods

toWidget :: (MonadWidget m, (* ~ HandlerSite m) site) => Css -> m () Source #

(~) * render (RY site) => ToWidget site (render -> Javascript) Source # 

Methods

toWidget :: (MonadWidget m, (* ~ HandlerSite m) site) => (render -> Javascript) -> m () Source #

(~) * render (RY site) => ToWidget site (render -> CssBuilder) Source # 

Methods

toWidget :: (MonadWidget m, (* ~ HandlerSite m) site) => (render -> CssBuilder) -> m () Source #

(~) * render (RY site) => ToWidget site (render -> Css) Source # 

Methods

toWidget :: (MonadWidget m, (* ~ HandlerSite m) site) => (render -> Css) -> m () Source #

(~) * render (RY site) => ToWidget site (render -> Html) Source # 

Methods

toWidget :: (MonadWidget m, (* ~ HandlerSite m) site) => (render -> Html) -> m () Source #

((~) * site' site, (~) (* -> *) IO m, (~) * a ()) => ToWidget site' (WidgetT site m a) Source # 

Methods

toWidget :: (MonadWidget m, (* ~ HandlerSite m) site') => WidgetT site m a -> m () Source #

class ToWidgetHead site a where Source #

Minimal complete definition

toWidgetHead

Methods

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

Instances

ToWidgetHead site Html Source # 

Methods

toWidgetHead :: (MonadWidget m, (* ~ HandlerSite m) site) => Html -> m () Source #

ToWidgetHead site Javascript Source # 

Methods

toWidgetHead :: (MonadWidget m, (* ~ HandlerSite m) site) => Javascript -> m () Source #

ToWidgetHead site CssBuilder Source # 

Methods

toWidgetHead :: (MonadWidget m, (* ~ HandlerSite m) site) => CssBuilder -> m () Source #

ToWidgetHead site Css Source # 

Methods

toWidgetHead :: (MonadWidget m, (* ~ HandlerSite m) site) => Css -> m () Source #

(~) * render (RY site) => ToWidgetHead site (render -> Javascript) Source # 

Methods

toWidgetHead :: (MonadWidget m, (* ~ HandlerSite m) site) => (render -> Javascript) -> m () Source #

(~) * render (RY site) => ToWidgetHead site (render -> CssBuilder) Source # 

Methods

toWidgetHead :: (MonadWidget m, (* ~ HandlerSite m) site) => (render -> CssBuilder) -> m () Source #

(~) * render (RY site) => ToWidgetHead site (render -> Css) Source # 

Methods

toWidgetHead :: (MonadWidget m, (* ~ HandlerSite m) site) => (render -> Css) -> m () Source #

(~) * render (RY site) => ToWidgetHead site (render -> Html) Source # 

Methods

toWidgetHead :: (MonadWidget m, (* ~ HandlerSite m) site) => (render -> Html) -> m () Source #

class ToWidgetBody site a where Source #

Minimal complete definition

toWidgetBody

Methods

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

Instances

ToWidgetBody site Html Source # 

Methods

toWidgetBody :: (MonadWidget m, (* ~ HandlerSite m) site) => Html -> m () Source #

ToWidgetBody site Javascript Source # 

Methods

toWidgetBody :: (MonadWidget m, (* ~ HandlerSite m) site) => Javascript -> m () Source #

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

Methods

toWidgetBody :: (MonadWidget m, (* ~ HandlerSite m) site) => (render -> Javascript) -> m () Source #

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

Methods

toWidgetBody :: (MonadWidget m, (* ~ HandlerSite m) site) => (render -> Html) -> m () Source #

class ToWidgetMedia site a where Source #

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

Since 1.2

Minimal complete definition

toWidgetMedia

Methods

toWidgetMedia :: (MonadWidget m, HandlerSite m ~ site) => Text -> a -> m () Source #

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

Since 1.2

Instances

ToWidgetMedia site CssBuilder Source # 

Methods

toWidgetMedia :: (MonadWidget m, (* ~ HandlerSite m) site) => Text -> CssBuilder -> m () Source #

ToWidgetMedia site Css Source # 

Methods

toWidgetMedia :: (MonadWidget m, (* ~ HandlerSite m) site) => Text -> Css -> m () Source #

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

Methods

toWidgetMedia :: (MonadWidget m, (* ~ HandlerSite m) site) => Text -> (render -> CssBuilder) -> m () Source #

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

Methods

toWidgetMedia :: (MonadWidget m, (* ~ HandlerSite m) site) => Text -> (render -> Css) -> m () Source #

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 Source # 

Methods

toWidgetHead :: (MonadWidget m, (* ~ HandlerSite m) site) => CssBuilder -> m () Source #

ToWidgetMedia site CssBuilder Source # 

Methods

toWidgetMedia :: (MonadWidget m, (* ~ HandlerSite m) site) => Text -> CssBuilder -> m () Source #

ToWidget site CssBuilder Source # 

Methods

toWidget :: (MonadWidget m, (* ~ HandlerSite m) site) => CssBuilder -> m () Source #

(~) * render (RY site) => ToWidgetHead site (render -> CssBuilder) Source # 

Methods

toWidgetHead :: (MonadWidget m, (* ~ HandlerSite m) site) => (render -> CssBuilder) -> m () Source #

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

Methods

toWidgetMedia :: (MonadWidget m, (* ~ HandlerSite m) site) => Text -> (render -> CssBuilder) -> m () Source #

(~) * render (RY site) => ToWidget site (render -> CssBuilder) Source # 

Methods

toWidget :: (MonadWidget m, (* ~ HandlerSite m) site) => (render -> CssBuilder) -> m () Source #

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 a Source #

Internal

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