yesod-0.6.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

newtype GWidget s m 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 s m a
 

Instances

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

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

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

Creating

Head of page

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

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

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

Add a Hamlet to the head tag.

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

Add a Html to the head tag.

Body

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

Add a Hamlet to the body tag.

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

Add a Html to the body tag.

addWidget :: GWidget s m () -> GWidget s m ()Source

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

CSS

addCassius :: 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.

Javascript

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

Include raw Javascript in the page's script tag.

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.

Utilities

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.

newIdent :: GWidget sub master StringSource

Get a unique identifier.