yesod-core-0.9.3.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

ToWidget sub master (GWidget sub master ()) 
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) 

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 -> HtmlUrl url

Constructors

PageContent 

Fields

pageTitle :: Html
 
pageHead :: HtmlUrl url
 
pageBody :: HtmlUrl url
 

Special Hamlet quasiquoter/TH for Widgets

ihamletToRepHtml :: (Monad mo, RenderMessage master message) => HtmlUrlI18n message (Route master) -> GGHandler sub master mo RepHtmlSource

Wraps the Content generated by hamletToContent in a RepHtml.

Convert to Widget

class ToWidget sub master a whereSource

Methods

toWidget :: a -> GWidget sub master ()Source

Instances

ToWidget sub master Html 
render ~ RY master => ToWidget sub master (render -> Coffeescript) 
render ~ RY master => ToWidget sub master (render -> Javascript) 
render ~ RY master => ToWidget sub master (render -> Css) 
render ~ RY master => ToWidget sub master (render -> Html) 
ToWidget sub master (GWidget sub master ()) 

class ToWidgetHead sub master a whereSource

Methods

toWidgetHead :: a -> GWidget sub master ()Source

Instances

ToWidgetHead sub master Html 
render ~ RY master => ToWidgetHead sub master (render -> Coffeescript) 
render ~ RY master => ToWidgetHead sub master (render -> Javascript) 
render ~ RY master => ToWidgetHead sub master (render -> Css) 
render ~ RY master => ToWidgetHead sub master (render -> Html) 

class ToWidgetBody sub master a whereSource

Methods

toWidgetBody :: a -> GWidget sub master ()Source

Instances

ToWidgetBody sub master Html 
render ~ RY master => ToWidgetBody sub master (render -> Coffeescript) 
render ~ RY master => ToWidgetBody sub master (render -> Javascript) 
render ~ RY master => ToWidgetBody sub master (render -> Html) 

Creating

Head of page

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

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

setTitleI :: (RenderMessage master msg, Monad m) => msg -> GGWidget master (GGHandler sub master m) ()Source

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

addHamletHead :: Monad m => HtmlUrl (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 => HtmlUrl (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 => CssUrl (Route master) -> GGWidget master m ()Source

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

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

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

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

Identical to addCassius.

addLuciusMedia :: Monad m => Text -> CssUrl (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 => JavascriptUrl (Route master) -> GGWidget master m ()Source

Include raw Javascript in the page's script tag.

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

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

addCoffee :: MonadIO m => CoffeeUrl (Route master) -> GGWidget master (GGHandler sub master m) ()Source

Add Coffesscript to the page's script tag. Requires the coffeescript executable to be present at runtime.

addCoffeeBody :: MonadIO m => CoffeeUrl (Route master) -> GGWidget master (GGHandler sub master m) ()Source

Add a new script tag to the body with the contents of this Coffesscript template. Requires the coffeescript executable to be present at runtime.

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 (HtmlUrl (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.