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.

[maintain] [Publish]

Warnings:

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]

Properties

Versions 0.0
Change log None available
Dependencies base (>=3 && <5), bytestring (>=0.10.4 && <0.11), text (>=1.2 && <1.3) [details]
License BSD-3-Clause
Author Ambiata, Tim Humphries
Maintainer tim@utf8.me
Category Web
Home page https://github.com/thumphries/hydrant
Bug tracker https://github.com/thumphries/hydrant
Uploaded by TimHumphries at 2017-10-06T07:56:58Z

Modules

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for hydrant-0.0

[back to package description]

hydrant

Very simple markup combinators for constructing HTML.

Usage

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