yesod-core-1.1.1.1: 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 Source

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) 
MonadLogger (GWidget sub master) 
MonadIO (GWidget sub master) 
MonadLift (GHandler sub master) (GWidget sub master) 
~ * a () => Monoid (GWidget sub master 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 :: RenderMessage master message => HtmlUrlI18n message (Route master) -> GHandler sub master 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 -> 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 whereSource

Methods

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

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 whereSource

Methods

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

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 ()Source

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

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

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

addHamletHead :: HtmlUrl (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 :: HtmlUrl (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 sub master () -> GWidget sub master ()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 :: CssUrl (Route master) -> GWidget sub master ()Source

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

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

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

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

Identical to addCassius.

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

Identical to addCassiusMedia.

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

Link to the specified local stylesheet.

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

Link to the specified local stylesheet.

addStylesheetRemote :: Text -> GWidget sub master ()Source

Link to the specified remote stylesheet.

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

Link to the specified remote stylesheet.

Javascript

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

Include raw Javascript in the page's script tag.

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

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

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

Link to the specified local script.

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

Link to the specified local script.

addScriptRemote :: Text -> GWidget sub master ()Source

Link to the specified remote script.

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

Link to the specified remote script.

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

Internal

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