yesod-core-1.6.14: 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

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

Deprecated: Use WidgetFor directly

data WidgetFor site 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
(site' ~ site, a ~ ()) => ToWidget site' (WidgetFor site a) Source # 
Instance details

Defined in Yesod.Core.Widget

Methods

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

Monad (WidgetFor site) Source # 
Instance details

Defined in Yesod.Core.Types

Methods

(>>=) :: WidgetFor site a -> (a -> WidgetFor site b) -> WidgetFor site b #

(>>) :: WidgetFor site a -> WidgetFor site b -> WidgetFor site b #

return :: a -> WidgetFor site a #

fail :: String -> WidgetFor site a #

Functor (WidgetFor site) Source # 
Instance details

Defined in Yesod.Core.Types

Methods

fmap :: (a -> b) -> WidgetFor site a -> WidgetFor site b #

(<$) :: a -> WidgetFor site b -> WidgetFor site a #

Applicative (WidgetFor site) Source # 
Instance details

Defined in Yesod.Core.Types

Methods

pure :: a -> WidgetFor site a #

(<*>) :: WidgetFor site (a -> b) -> WidgetFor site a -> WidgetFor site b #

liftA2 :: (a -> b -> c) -> WidgetFor site a -> WidgetFor site b -> WidgetFor site c #

(*>) :: WidgetFor site a -> WidgetFor site b -> WidgetFor site b #

(<*) :: WidgetFor site a -> WidgetFor site b -> WidgetFor site a #

MonadIO (WidgetFor site) Source # 
Instance details

Defined in Yesod.Core.Types

Methods

liftIO :: IO a -> WidgetFor site a #

MonadUnliftIO (WidgetFor site) Source #

Since: 1.4.38

Instance details

Defined in Yesod.Core.Types

Methods

askUnliftIO :: WidgetFor site (UnliftIO (WidgetFor site)) #

withRunInIO :: ((forall a. WidgetFor site a -> IO a) -> IO b) -> WidgetFor site b #

MonadResource (WidgetFor site) Source # 
Instance details

Defined in Yesod.Core.Types

Methods

liftResourceT :: ResourceT IO a -> WidgetFor site a #

PrimMonad (WidgetFor site) Source #

Since: 1.6.7

Instance details

Defined in Yesod.Core.Types

Associated Types

type PrimState (WidgetFor site) :: Type #

Methods

primitive :: (State# (PrimState (WidgetFor site)) -> (#State# (PrimState (WidgetFor site)), a#)) -> WidgetFor site a #

MonadThrow (WidgetFor site) Source # 
Instance details

Defined in Yesod.Core.Types

Methods

throwM :: Exception e => e -> WidgetFor site a #

MonadLogger (WidgetFor site) Source # 
Instance details

Defined in Yesod.Core.Types

Methods

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

MonadLoggerIO (WidgetFor site) Source # 
Instance details

Defined in Yesod.Core.Types

Methods

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

MonadWidget (WidgetFor site) Source # 
Instance details

Defined in Yesod.Core.Class.Handler

Methods

liftWidget :: WidgetFor (HandlerSite (WidgetFor site)) a -> WidgetFor site a Source #

MonadHandler (WidgetFor site) Source # 
Instance details

Defined in Yesod.Core.Class.Handler

Associated Types

type HandlerSite (WidgetFor site) :: Type Source #

type SubHandlerSite (WidgetFor site) :: Type Source #

MonadReader (WidgetData site) (WidgetFor site) Source # 
Instance details

Defined in Yesod.Core.Types

Methods

ask :: WidgetFor site (WidgetData site) #

local :: (WidgetData site -> WidgetData site) -> WidgetFor site a -> WidgetFor site a #

reader :: (WidgetData site -> a) -> WidgetFor site a #

a ~ () => IsString (WidgetFor site 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"
Instance details

Defined in Yesod.Core.Types

Methods

fromString :: String -> WidgetFor site a #

a ~ () => Semigroup (WidgetFor site a) Source # 
Instance details

Defined in Yesod.Core.Types

Methods

(<>) :: WidgetFor site a -> WidgetFor site a -> WidgetFor site a #

sconcat :: NonEmpty (WidgetFor site a) -> WidgetFor site a #

stimes :: Integral b => b -> WidgetFor site a -> WidgetFor site a #

a ~ () => Monoid (WidgetFor site a) Source # 
Instance details

Defined in Yesod.Core.Types

Methods

mempty :: WidgetFor site a #

mappend :: WidgetFor site a -> WidgetFor site a -> WidgetFor site a #

mconcat :: [WidgetFor site a] -> WidgetFor site a #

type PrimState (WidgetFor site) Source # 
Instance details

Defined in Yesod.Core.Types

type HandlerSite (WidgetFor site) Source # 
Instance details

Defined in Yesod.Core.Class.Handler

type HandlerSite (WidgetFor site) = site
type SubHandlerSite (WidgetFor site) Source # 
Instance details

Defined in Yesod.Core.Class.Handler

type SubHandlerSite (WidgetFor site) = 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 #

Methods

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

Instances
ToWidget site Builder Source #

Since: 1.4.28

Instance details

Defined in Yesod.Core.Widget

Methods

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

ToWidget site Text Source #

Since: 1.4.28

Instance details

Defined in Yesod.Core.Widget

Methods

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

ToWidget site Text Source #

Since: 1.4.28

Instance details

Defined in Yesod.Core.Widget

Methods

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

ToWidget site Html Source # 
Instance details

Defined in Yesod.Core.Widget

Methods

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

ToWidget site Javascript Source # 
Instance details

Defined in Yesod.Core.Widget

Methods

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

ToWidget site CssBuilder Source # 
Instance details

Defined in Yesod.Core.Widget

Methods

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

ToWidget site Css Source # 
Instance details

Defined in Yesod.Core.Widget

Methods

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

(site' ~ site, a ~ ()) => ToWidget site' (WidgetFor site a) Source # 
Instance details

Defined in Yesod.Core.Widget

Methods

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

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

Defined in Yesod.Core.Widget

Methods

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

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

Defined in Yesod.Core.Widget

Methods

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

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

Defined in Yesod.Core.Widget

Methods

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

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

Defined in Yesod.Core.Widget

Methods

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

class ToWidgetHead site a where Source #

Methods

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

Instances
ToWidgetHead site Html Source # 
Instance details

Defined in Yesod.Core.Widget

Methods

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

ToWidgetHead site Javascript Source # 
Instance details

Defined in Yesod.Core.Widget

Methods

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

ToWidgetHead site CssBuilder Source # 
Instance details

Defined in Yesod.Core.Widget

Methods

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

ToWidgetHead site Css Source # 
Instance details

Defined in Yesod.Core.Widget

Methods

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

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

Defined in Yesod.Core.Widget

Methods

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

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

Defined in Yesod.Core.Widget

Methods

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

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

Defined in Yesod.Core.Widget

Methods

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

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

Defined in Yesod.Core.Widget

Methods

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

class ToWidgetBody site a where Source #

Methods

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

Instances
ToWidgetBody site Html Source # 
Instance details

Defined in Yesod.Core.Widget

Methods

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

ToWidgetBody site Javascript Source # 
Instance details

Defined in Yesod.Core.Widget

Methods

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

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

Defined in Yesod.Core.Widget

Methods

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

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

Defined in Yesod.Core.Widget

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

Methods

toWidgetMedia Source #

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

Defined in Yesod.Core.Widget

Methods

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

ToWidgetMedia site Css Source # 
Instance details

Defined in Yesod.Core.Widget

Methods

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

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

Defined in Yesod.Core.Widget

Methods

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

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

Defined in Yesod.Core.Widget

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 # 
Instance details

Defined in Yesod.Core.Widget

Methods

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

ToWidgetMedia site CssBuilder Source # 
Instance details

Defined in Yesod.Core.Widget

Methods

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

ToWidget site CssBuilder Source # 
Instance details

Defined in Yesod.Core.Widget

Methods

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

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

Defined in Yesod.Core.Widget

Methods

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

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

Defined in Yesod.Core.Widget

Methods

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

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

Defined in Yesod.Core.Widget

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

Internal

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