Contents

Description

Build HTML tables using lucid and colonnade. It is recommended that users read the documentation for colonnade first, since this library builds on the abstractions introduced there. Also, look at the docs for blaze-colonnade. These two libraries are similar, but blaze offers an HTML pretty printer which makes it possible to doctest examples. Since lucid does not offer such facilities, examples are omitted here.

Synopsis

# Apply

Arguments

 :: (Headedness h, Foldable f, Monoid d) => [Attribute] Attributes of  element -> Colonnade h a (Html d) How to encode data as columns -> f a Collection of data -> Html d

Encode a table. Table cell element do not have any attributes applied to them.

Arguments

 :: (Headedness h, Foldable f, Monoid d) => [Attribute] Attributes of  element -> Colonnade h a (Cell d) How to encode data as columns -> f a Collection of data -> Html d

Encode a table. Table cells may have attributes applied to them

Arguments

 :: (Foldable f, Headedness h, Monoid d) => h ([Attribute], [Attribute]) Attributes of 
and its  -> [Attribute] Attributes of 
element -> (a -> [Attribute]) Attributes of each  element -> (([Attribute] -> Html d -> Html d) -> c -> Html d) Wrap content and convert to Html -> [Attribute] Attributes of  element -> Colonnade h a c How to encode data as a row -> f a Collection of data -> Html d

Encode a table. This handles a very general case and is seldom needed by users. One of the arguments provided is used to add attributes to the generated <tr> elements. The elements of type d produced by generating html are strictly combined with their monoidal append function. However, this type is nearly always ().

# Cell

The Cell type is used to build a Colonnade that has Html content inside table cells and may optionally have attributes added to the <td> or <th> elements that wrap this HTML content.

data Cell d Source #

The attributes that will be applied to a <td> and the HTML content that will go inside it. When using this type, remember that Attribute, defined in blaze-markup, is actually a collection of attributes, not a single attribute.

Constructors

 Cell FieldscellAttribute :: ![Attribute] cellHtml :: !(Html d)

Instances

 (~) * d () => IsString (Cell d) Source # Methods Semigroup d => Semigroup (Cell d) Source # Methods(<>) :: Cell d -> Cell d -> Cell d #sconcat :: NonEmpty (Cell d) -> Cell d #stimes :: Integral b => b -> Cell d -> Cell d # Monoid d => Monoid (Cell d) Source # Methodsmempty :: Cell d #mappend :: Cell d -> Cell d -> Cell d #mconcat :: [Cell d] -> Cell d #

htmlCell :: Html d -> Cell d Source #

Create a Cell from a Widget

Create a Cell from a String

textCell :: Text -> Cell () Source #

Create a Cell from a Text

Create a Cell from a lazy text

Create a Cell from a text builder

htmlFromCell :: ([Attribute] -> Html d -> Html d) -> Cell d -> Html d Source #

Convert a Cell to Html by wrapping the content with a tag and applying the Cell attributes to that tag.

# Discussion

In this module, some of the functions for applying a Colonnade to some values to build a table have roughly this type signature:

Foldable a => Colonnade Headedness a (Cell d) -> f a -> Html d

The Colonnade content type is Cell, but the content type of the result is Html. It may not be immidiately clear why this is done. Another strategy, which this library also uses, is to write these functions to take a Colonnade whose content is Html:

Foldable a => Colonnade Headedness a (Html d) -> f a -> Html d

When the Colonnade content type is Html, then the header content is rendered as the child of a <th> and the row content the child of a <td>. However, it is not possible to add attributes to these parent elements. To accomodate this situation, it is necessary to introduce Cell, which includes the possibility of attributes on the parent node.