yesod-0.5.4.2: 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

newtype GWidget sub master 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 (WriterT (Body (Route master)) (WriterT (Last Title) (WriterT (UniqueList (Script (Route master))) (WriterT (UniqueList (Stylesheet (Route master))) (WriterT (Maybe (Cassius (Route master))) (WriterT (Maybe (Julius (Route master))) (WriterT (Head (Route master)) (StateT Int (GHandler sub master)))))))) a) 

Instances

Monad (HamletMonad (GWidget s m ())) 
Monad (GWidget sub master) 
Functor (GWidget sub master) 
Applicative (GWidget sub master) 
MonadCatchIO (GWidget sub master) 
MonadIO (GWidget sub master) 
Monoid (GWidget sub master ()) 
HamletValue (GWidget s m ()) 

type Widget y = GWidget y ySource

A GWidget specialized to when the subsite and master site are the same.

liftHandler :: GHandler sub master a -> GWidget sub master aSource

Lift an action in the GHandler monad into an action in the GWidget monad.

Creating

newIdent :: GWidget sub master StringSource

Get a unique identifier.

setTitle :: Html -> GWidget sub master ()Source

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

addStyle :: Cassius (Route master) -> GWidget sub master ()Source

Add some raw CSS to the style tag.

addStylesheet :: Route master -> GWidget sub master ()Source

Link to the specified local stylesheet.

addStylesheetRemote :: String -> GWidget sub master ()Source

Link to the specified remote stylesheet.

addScript :: Route master -> GWidget sub master ()Source

Link to the specified local script.

addScriptRemote :: String -> GWidget sub master ()Source

Link to the specified remote script.

addHead :: Hamlet (Route master) -> GWidget sub master ()Source

Add some raw HTML to the head tag.

addBody :: Hamlet (Route master) -> GWidget sub master ()Source

Add some raw HTML to the body tag.

addJavascript :: Julius (Route master) -> GWidget sub master ()Source

Include raw Javascript in the page's script tag.

Manipulating

wrapWidget :: GWidget s m a -> (Hamlet (Route m) -> Hamlet (Route m)) -> GWidget s m aSource

Modify the given GWidget by wrapping the body tag HTML code with the given function. You might also consider using extractBody.

extractBody :: GWidget s m () -> GWidget s m (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.