yesod-core-1.0.1.2: Creation of type-safe, RESTful web applications.

Safe HaskellNone

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

A generic widget, allowing specification of both the subsite and master site datatypes. While this is simply a WriterT, we define a newtype for better error messages.

Instances

(~ * sub' sub, ~ * master' master) => ToWidget sub' master' (GWidget sub master ()) 
MonadBase IO (GWidget sub master) 
MonadBaseControl IO (GWidget sub master) 
Monad (GWidget sub master) 
Functor (GWidget sub master) 
Applicative (GWidget sub master) 
MonadUnsafeIO (GWidget sub master) 
MonadThrow (GWidget sub master) 
MonadResource (GWidget sub master) 
MonadIO (GWidget sub master) 
MonadLift (GHandler sub master) (GWidget sub master) 
~ * a () => Monoid (GWidget sub master a) 

data PageContent url

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 :: RenderMessage master message => HtmlUrlI18n message (Route master) -> GHandler sub master RepHtml

Wraps the Content generated by hamletToContent in a RepHtml.

Convert to Widget

class ToWidget sub master a where

Methods

toWidget :: a -> GWidget sub master ()

Instances

ToWidget sub master Html 
~ * render (RY master) => ToWidget sub master (render -> Javascript) 
~ * render (RY master) => ToWidget sub master (render -> Css) 
~ * render (RY master) => ToWidget sub master (render -> Html) 
(~ * sub' sub, ~ * master' master) => ToWidget sub' master' (GWidget sub master ()) 

class ToWidgetHead sub master a where

Methods

toWidgetHead :: a -> GWidget sub master ()

Instances

ToWidgetHead sub master Html 
~ * 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 where

Methods

toWidgetBody :: a -> GWidget sub master ()

Instances

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

Creating

Head of page

setTitle :: Html -> GWidget sub master ()

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

setTitleI :: RenderMessage master msg => msg -> GWidget sub master ()

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

addHamletHead :: HtmlUrl (Route master) -> GWidget sub master ()

Add a Hamlet to the head tag.

addHtmlHead :: Html -> GWidget sub master ()

Add a Html to the head tag.

Body

addHamlet :: HtmlUrl (Route master) -> GWidget sub master ()

Add a Hamlet to the body tag.

addHtml :: Html -> GWidget sub master ()

Add a Html to the body tag.

addWidget :: GWidget sub master () -> GWidget sub master ()

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 a

CSS

addCassius :: CssUrl (Route master) -> GWidget sub master ()

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

addCassiusMedia :: Text -> CssUrl (Route master) -> GWidget sub master ()

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

addLucius :: CssUrl (Route master) -> GWidget sub master ()

Identical to addCassius.

addLuciusMedia :: Text -> CssUrl (Route master) -> GWidget sub master ()

Identical to addCassiusMedia.

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

Link to the specified local stylesheet.

addStylesheetAttrs :: Route master -> [(Text, Text)] -> GWidget sub master ()

Link to the specified local stylesheet.

addStylesheetRemote :: Text -> GWidget sub master ()

Link to the specified remote stylesheet.

addStylesheetRemoteAttrs :: Text -> [(Text, Text)] -> GWidget sub master ()

Link to the specified remote stylesheet.

addStylesheetEither :: Either (Route master) Text -> GWidget sub master ()

Javascript

addJulius :: JavascriptUrl (Route master) -> GWidget sub master ()

Include raw Javascript in the page's script tag.

addJuliusBody :: JavascriptUrl (Route master) -> GWidget sub master ()

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

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

Link to the specified local script.

addScriptAttrs :: Route master -> [(Text, Text)] -> GWidget sub master ()

Link to the specified local script.

addScriptRemote :: Text -> GWidget sub master ()

Link to the specified remote script.

addScriptRemoteAttrs :: Text -> [(Text, Text)] -> GWidget sub master ()

Link to the specified remote script.

addScriptEither :: Either (Route master) Text -> GWidget sub master ()

Internal

unGWidget :: GWidget sub master a -> GHandler sub master (a, GWData (Route master))