yesod-core-0.7.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 s m (GHandler s m)Source

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

Instances

(a ~ (), Monad monad) => Monad (HamletMonad (GGWidget s m monad a)) 
MonadTrans (GGWidget s m) 
Monad monad => Monad (GGWidget s m monad) 
Functor monad => Functor (GGWidget s m monad) 
(Monad monad, Functor monad) => Applicative (GGWidget s m monad) 
MonadPeelIO monad => MonadPeelIO (GGWidget s m monad) 
MonadIO monad => MonadIO (GGWidget s m monad) 
(a ~ (), Monad monad) => Monoid (GGWidget sub master monad a) 
(a ~ (), Monad monad) => HamletValue (GGWidget s 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 sub master m ()Source

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

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

Add a Hamlet to the head tag.

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

Add a Html to the head tag.

Body

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

Add a Hamlet to the body tag.

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

Add a Html to the body tag.

addWidget :: Monad mo => GGWidget s m mo () -> GGWidget s 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 sub master m ()Source

Add some raw CSS to the style tag.

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

Link to the specified local stylesheet.

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

Link to the specified remote stylesheet.

addStylesheetEither :: Monad m => Either (Route master) String -> GGWidget sub master m ()Source

Javascript

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

Include raw Javascript in the page's script tag.

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

Link to the specified local script.

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

Link to the specified remote script.

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

Utilities

extractBody :: Monad mo => GGWidget s m mo () -> GGWidget s 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.