Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- newtype View context a = View {}
- data ViewState = ViewState {}
- runView :: context -> View context () -> ViewState
- context :: View context context
- addContext :: context -> View context () -> View c ()
- viewModContents :: ([Content] -> [Content]) -> View context ()
- viewModCss :: (CSS -> CSS) -> View context ()
- viewAddClasses :: [Class] -> View c ()
- viewAddContent :: Content -> View c ()
- viewInsertContents :: [Content] -> View c ()
- tag :: Text -> Mod c -> View c () -> View c ()
- tag' :: (Attributes c -> [Content] -> Element) -> Mod c -> View c () -> View c ()
- att :: Name -> AttValue -> Mod c
Views
newtype View context a Source #
Views are HTML fragments that carry all CSS
used by any child element.
view :: View c () view = col (pad 10 . gap 10) $ do el bold "Hello" el_ "World"
They can also have a context which can be used to create type-safe or context-aware elements. See context
or table
for an example
context :: View context context Source #
Views have a Reader
built-in for convienient access to static data, and to add type-safety to view functions. See table
and https://hackage.haskell.org/package/hyperbole/docs/Web-Hyperbole.html
numberView :: View Int () numberView = do num <- context el_ $ do "Number: " text (pack $ show num)
addContext :: context -> View context () -> View c () Source #
viewAddClasses :: [Class] -> View c () Source #
viewAddContent :: Content -> View c () Source #
viewInsertContents :: [Content] -> View c () Source #
Inserts contents into the first child element
Creating new Elements
tag :: Text -> Mod c -> View c () -> View c () Source #
Create a new element constructor with the given tag name
aside :: Mod c -> View c () -> View c () aside = tag "aside"