# Web View Colonnade Build HTML tables using [colonnade](https://hackage.haskell.org/package/colonnade) and rendering with the [web-view](https://hackage.haskell.org/package/web-view) library in Haskell. This library provides functionality similar to `lucid-colonnade` and `blaze-colonnade`, but for the web-view library. It lets you build complex HTML tables with minimal boilerplate. ## Installation Add the following to your `package.yaml` or `.cabal` file: ```yaml dependencies: - colonnade - web-view - web-view-colonnade ``` ## Examples ### Basic Example ```haskell {-# LANGUAGE OverloadedStrings #-} import qualified Data.Text as T import qualified Colonnade as C import qualified Web.View.View as V import qualified Web.View.Element as E import Web.View (renderText) import WebView.Colonnade -- Define a data type to represent our data data Person = Person { name :: T.Text , age :: Int } -- Define some data people :: [Person] people = [ Person "Alice" 30 , Person "Bob" 25 , Person "Carol" 35 ] -- Define the table structure personTable :: C.Colonnade C.Headed Person (V.View c ()) personTable = mconcat [ C.headed "Name" (E.text . name) , C.headed "Age" (E.text . T.pack . show . age) ] main :: IO () main = do -- Render a table with custom attributes let html = encodeHtmlTable (V.extClass "person-table") personTable people putStrLn $ renderText html ``` This produces: ```html
Name | Age |
---|---|
Alice | 30 |
Bob | 25 |
Carol | 35 |