Widgets combine HTML with JS and CSS dependencies with a unique identifier generator, allowing you to create truly modular HTML components.
- newtype GWidget sub master a = GWidget (WriterT (Body (Route master)) (WriterT (Last Title) (WriterT (UniqueList (Script (Route master))) (WriterT (UniqueList (Stylesheet (Route master))) (WriterT (Maybe (Cassius (Route master))) (WriterT (Maybe (Julius (Route master))) (WriterT (Head (Route master)) (StateT Int (GHandler sub master)))))))) a)
- type Widget y = GWidget y y
- liftHandler :: GHandler sub master a -> GWidget sub master a
- newIdent :: GWidget sub master String
- setTitle :: Html -> GWidget sub master ()
- addStyle :: Cassius (Route master) -> GWidget sub master ()
- addStylesheet :: Route master -> GWidget sub master ()
- addStylesheetRemote :: String -> GWidget sub master ()
- addStylesheetEither :: Either (Route master) String -> GWidget sub master ()
- addScript :: Route master -> GWidget sub master ()
- addScriptRemote :: String -> GWidget sub master ()
- addScriptEither :: Either (Route master) String -> GWidget sub master ()
- addHead :: Hamlet (Route master) -> GWidget sub master ()
- addBody :: Hamlet (Route master) -> GWidget sub master ()
- addJavascript :: Julius (Route master) -> GWidget sub master ()
- wrapWidget :: GWidget s m a -> (Hamlet (Route m) -> Hamlet (Route m)) -> GWidget s m a
- extractBody :: GWidget s m () -> GWidget s m (Hamlet (Route m))
Datatype
newtype 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.
GWidget (WriterT (Body (Route master)) (WriterT (Last Title) (WriterT (UniqueList (Script (Route master))) (WriterT (UniqueList (Stylesheet (Route master))) (WriterT (Maybe (Cassius (Route master))) (WriterT (Maybe (Julius (Route master))) (WriterT (Head (Route master)) (StateT Int (GHandler sub master)))))))) a) |
Monad (HamletMonad (GWidget s m ())) | |
Monad (GWidget sub master) | |
Functor (GWidget sub master) | |
Applicative (GWidget sub master) | |
MonadCatchIO (GWidget sub master) | |
MonadIO (GWidget sub master) | |
Monoid (GWidget sub master ()) | |
HamletValue (GWidget s m ()) |
type Widget y = GWidget y ySource
A GWidget
specialized to when the subsite and master site are the same.
liftHandler :: GHandler sub master a -> GWidget sub master aSource
Creating
setTitle :: Html -> GWidget sub master ()Source
Set the page title. Calling setTitle
multiple times overrides previously
set values.
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.
addScriptRemote :: String -> GWidget sub master ()Source
Link to the specified remote script.
addJavascript :: Julius (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
.