BlazeHtml is a blazingly fast HTML combinator library for the Haskell programming language. It embeds HTML templates in Haskell code for optimal efficiency and composability.
I think Yesod uses this package for HTML generation. At any rate, I came across this package
when I needed to inject HTML into a page that was getting escaped. The function preEscapedToHtml
did the trick. See https://jaspervdj.be/blaze/docs/Text-Blaze-Html.html.
blaze-html
comes with Stack. You can add it to your project's package.yaml
.
preEscapedToHtml
This function is used on the Haskell Roulette website to output the HTML pre-generated by the CMark package.
In particular, the getPackageR
handler:
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
module Handler.Package where
import Import
import Text.Blaze.Html (preEscapedToHtml)
getPackageR :: HaskellPackageId -> Handler Html
getPackageR name = do
package <- runDB $ get404 name
defaultLayout $ do
setTitle "Welcome To Package!"
$(widgetFile "package")
And the package.hamlet
template:
<div .masthead>
<div .container>
<div .row>
<h1 .header>
Package #{haskellPackageName package}!
<div .container>
<div .bs-docs-section>
$maybe notes <- (haskellPackageNotes package)
#{preEscapedToHtml notes}
$nothing
<p>No notes yet.