hydrant: Simple HTML combinators

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.



Simple HTML combinators.

Hydrant provides everything you need to construct markup at a low, low cost.

It distinguishes itself from libraries like Blaze and Lucid by being extremely simple in both API and implementation. Hydrant is comprised entirely of lazy Text builders, newtypes, and simple inlineable combinators. It has a negligible dependency footprint, requiring only bytestring and text.

While this simple implementation means your markup cannot be inspected after it is built, it also means a simpler API and far less runtime overhead during construction.

[Skip to ReadMe]


Change logNone available
Dependenciesbase (>=3 && <5), bytestring (>=0.10.4 && <0.11), text (==1.2.*) [details]
AuthorAmbiata, Tim Humphries
Home pagehttps://github.com/thumphries/hydrant
Bug trackerhttps://github.com/thumphries/hydrant
UploadedFri Oct 6 07:56:58 UTC 2017 by TimHumphries



Maintainers' corner

For package maintainers and hackage trustees

Readme for hydrant-0.0

[back to package description]


Very simple markup combinators for constructing HTML.


Hydrant is not meant to be a particularly nice DSL, just a simple one. If you want to construct some dirt-simple HTML in a small application, or render HTML from a templating language, you're in the right place.

module HydrantDemo where

import Data.Foldable
import Data.Text
import qualified Data.Text as T
import qualified Data.Text.Lazy as LT
import Hydrant
import System.IO (FilePath)

data Foo
  = FooPara Text [Foo]
  | FooImg FilePath

view :: Foo -> Html
view f =
  case f of
    FooPara t foos ->
      parentNode (Tag "p") [] (textNode t <> fold (fmap view foos))
    FooImg fp ->
      voidNode (Tag "img") [
          Attribute (AttributeKey "src") (AttributeValue (T.pack fp))

renderFooHtml :: Foo -> LT.Text
renderFooHtml =
  toLazyText . view