Presenting results in an HTML web page
Sharing data online is one of the quickest ways to reach a broad audience. However, typing data into HTML directly can be time consuming. This recipe will generate a web page using the Blaze Haskell library to present data results. For more documentation and tutorials, visit the project webpage at http://jaspervdj.be/blaze/.
Getting ready
Install the Blaze package from cabal using the following command:
$ cabal install blaze-html
How to do it…
In a new file called Main.hs
, perform the following steps:
- Import all the necessary libraries as follows:
{-# LANGUAGE OverloadedStrings #-} import Control.Monad (forM_) import Text.Blaze.Html5 import qualified Text.Blaze.Html5 as H import Text.Blaze.Html.Renderer.Utf8 (renderHtml) import qualified Data.ByteString.Lazy as BSL
- Convert the list of string into an HTML unordered list as shown in the following code snippet:
dataInList :: Html -> [String] -> Html dataInList label items = docTypeHtml $ do ...