Widgets combine HTML with JS and CSS dependencies with a unique identifier generator, allowing you to create truly modular HTML components.
- type GWidget s m = GGWidget s m (GHandler s m)
- newtype GGWidget s m monad a = GWidget {
- unGWidget :: GWInner s m monad a
- data PageContent url = PageContent {}
- setTitle :: Monad m => Html -> GGWidget sub master m ()
- addHamletHead :: Monad m => Hamlet (Route master) -> GGWidget sub master m ()
- addHtmlHead :: Monad m => Html -> GGWidget sub master m ()
- addHamlet :: Monad m => Hamlet (Route master) -> GGWidget sub master m ()
- addHtml :: Monad m => Html -> GGWidget sub master m ()
- addWidget :: Monad mo => GGWidget s m mo () -> GGWidget s m mo ()
- addSubWidget :: YesodSubRoute sub master => sub -> GWidget sub master a -> GWidget sub' master a
- addCassius :: Monad m => Cassius (Route master) -> GGWidget sub master m ()
- addStylesheet :: Monad m => Route master -> GGWidget sub master m ()
- addStylesheetRemote :: Monad m => String -> GGWidget sub master m ()
- addStylesheetEither :: Monad m => Either (Route master) String -> GGWidget sub master m ()
- addJulius :: Monad m => Julius (Route master) -> GGWidget sub master m ()
- addScript :: Monad m => Route master -> GGWidget sub master m ()
- addScriptRemote :: Monad m => String -> GGWidget sub master m ()
- addScriptEither :: Monad m => Either (Route master) String -> GGWidget sub master m ()
- extractBody :: Monad mo => GGWidget s m mo () -> GGWidget s m mo (Hamlet (Route m))
Datatype
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.
(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
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.
Body
addHamlet :: Monad m => Hamlet (Route master) -> GGWidget sub master m ()Source
Add a Hamlet
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.
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.