Piggies love embracing template!
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
LICENSE
PigLet.cabal
README.md
Setup.hs

README.md

PigLet

Piglet sleeping

Piggies love embracing templates!

PigLet is an HTML template libary that transforms HTML5 files into Blaze HTML using template Haskell.

It's currently under initial development. Hopefully it could provide a Haskell equivalent to Clojure's wonderful Enlive.

Example

Let's say you have an HTML file called hello.html:

<html>
  <head>
      <title>Hello World!</title>
  </head>
  <body>
      <div class="page"></div>
  </body>
</html>

With the following code:

import           Text.Html.PigLet
import qualified Text.Blaze.Html5 as H


page = defTemplate [] "hello.html" [
  D "title"             >@< embedContent [| H.toHtml "Hello Piggies!" |]
, A ("class", ["page"]) >@< updateAttr [| addAttr ("id", "page-wrapper") |]
]

it's expected to see when the page is rendered:

<html>
  <head>
      <title>Hello Piggies!</title>
  </head>
  <body>
      <div class="page" id="page-wrapper"></div>
  </body>
</html>

Todo

  1. More composable HTML transformations
  2. Compile time error checkings
  3. Better template syntax, more efficient attributes generator