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

data 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.

Instances

Monad (GWidget sub master) 
Functor (GWidget sub master) 
Applicative (GWidget sub master) 
MonadCatchIO (GWidget sub master) 
MonadIO (GWidget sub master) 
Monoid (GWidget sub master ()) 

type Widget y = GWidget y ySource

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

Unwrapping

widgetToPageContent :: Eq (Route master) => GWidget sub master () -> GHandler sub master (PageContent (Route master))Source

Convert a widget to a PageContent.

applyLayoutW :: (Eq (Route m), Yesod m) => GWidget sub m () -> GHandler sub m RepHtmlSource

Apply the default layout to the given widget.

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 :: Hamlet (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 :: Hamlet (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.

Default library URLs

urlJqueryJs :: StringSource

The Google-hosted jQuery 1.4.2 file.

urlJqueryUiJs :: StringSource

The Google-hosted jQuery UI 1.8.1 javascript file.

urlJqueryUiCss :: StringSource

The Google-hosted jQuery UI 1.8.1 CSS file with cupertino theme.