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

Yesod.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 GWidget s m = GGWidget m (GHandler s m)Source

newtype GGWidget m monad a Source

A generic widget, allowing specification of both the subsite and master site datatypes. This is basically a large WriterT stack keeping track of dependencies along with a StateT to track unique identifiers.

Constructors

GWidget 

Fields

unGWidget :: GWInner m monad a
 

Instances

(a ~ (), Monad monad) => Monad (HamletMonad (GGWidget m monad a)) 
MonadTrans (GGWidget m) 
Monad monad => Monad (GGWidget m monad) 
Functor monad => Functor (GGWidget m monad) 
(Monad monad, Functor monad) => Applicative (GGWidget m monad) 
MonadIO monad => MonadIO (GGWidget m monad) 
MonadControlIO monad => MonadControlIO (GGWidget m monad) 
(a ~ (), Monad monad) => Monoid (GGWidget master monad a) 
(a ~ (), Monad monad) => HamletValue (GGWidget m monad 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 -> Hamlet url

Constructors

PageContent 

Fields

pageTitle :: Html
 
pageHead :: Hamlet url
 
pageBody :: Hamlet url
 

Creating

Head of page

setTitle :: Monad m => Html -> GGWidget master m ()Source

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

addHamletHead :: Monad m => Hamlet (Route master) -> GGWidget master m ()Source

Add a Hamlet to the head tag.

addHtmlHead :: Monad m => Html -> GGWidget master m ()Source

Add a Html to the head tag.

Body

addHamlet :: Monad m => Hamlet (Route master) -> GGWidget master m ()Source

Add a Hamlet to the body tag.

addHtml :: Monad m => Html -> GGWidget master m ()Source

Add a Html to the body tag.

addWidget :: Monad mo => GGWidget m mo () -> GGWidget m mo ()Source

Add another widget. This is defined as id, by can help with types, and makes widget blocks look more consistent.

addSubWidget :: YesodSubRoute sub master => sub -> GWidget sub master a -> GWidget sub' master aSource

CSS

addCassius :: Monad m => Cassius (Route master) -> GGWidget master m ()Source

Add some raw CSS to the style tag. Applies to all media types.

addCassiusMedia :: Monad m => Text -> Cassius (Route master) -> GGWidget master m ()Source

Add some raw CSS to the style tag, for a specific media type.

addLucius :: Monad m => Lucius (Route master) -> GGWidget master m ()Source

Identical to addCassius.

addLuciusMedia :: Monad m => Text -> Lucius (Route master) -> GGWidget master m ()Source

Identical to addCassiusMedia.

addStylesheet :: Monad m => Route master -> GGWidget master m ()Source

Link to the specified local stylesheet.

addStylesheetAttrs :: Monad m => Route master -> [(Text, Text)] -> GGWidget master m ()Source

Link to the specified local stylesheet.

addStylesheetRemote :: Monad m => Text -> GGWidget master m ()Source

Link to the specified remote stylesheet.

addStylesheetRemoteAttrs :: Monad m => Text -> [(Text, Text)] -> GGWidget master m ()Source

Link to the specified remote stylesheet.

Javascript

addJulius :: Monad m => Julius (Route master) -> GGWidget master m ()Source

Include raw Javascript in the page's script tag.

addJuliusBody :: Monad m => Julius (Route master) -> GGWidget master m ()Source

Add a new script tag to the body with the contents of this Julius template.

addScript :: Monad m => Route master -> GGWidget master m ()Source

Link to the specified local script.

addScriptAttrs :: Monad m => Route master -> [(Text, Text)] -> GGWidget master m ()Source

Link to the specified local script.

addScriptRemote :: Monad m => Text -> GGWidget master m ()Source

Link to the specified remote script.

addScriptRemoteAttrs :: Monad m => Text -> [(Text, Text)] -> GGWidget master m ()Source

Link to the specified remote script.

addScriptEither :: Monad m => Either (Route master) Text -> GGWidget master m ()Source

Utilities

extractBody :: Monad mo => GGWidget m mo () -> GGWidget m mo (Hamlet (Route m))Source

Pull out the HTML tag contents and return it. Useful for performing some manipulations. It can be easier to use this sometimes than wrapWidget.