Using blaze to create an HTML template
In this recipe, we will be using the blaze-html library to construct HTML documents. The blaze-html library provides very efficient and fast DSL for constructing HTML documents. It is very lightweight and supports efficient UNICODE support. Being that it is embedded inside Haskell, one can also take full advantage of Haskell while constructing HTML documents. It also supports HTML5 and HTML4 strict syntax.
Note that the aim of the recipe is not to showcase HTML, but the interoperability between Haskell and HTML through blaze-html.
How to do it...
- Create a new project,
working-with-blaze-html
, withsimple
stack template:
stack new working-with-blaze-html simple
- Add a dependency on the
blaze-html
library in thebuild-depends
sub-section of theexecutable
section:
executable blaze-html hs-source-dirs: src main-is: Main.hs default-language: Haskell2010 build-depends: base >=...