Hack utilities to render Text.Press templates to responses
Haskell
Switch branches/tags
Nothing to show
Permalink
Failed to load latest commit information.
Hack/Contrib cleanups Jul 25, 2009
examples Add a small example Jul 25, 2009
LICENSE initial commit Jul 25, 2009
Makefile initial commit Jul 25, 2009
README.md take four Jul 25, 2009
Setup.hs cleanups Jul 25, 2009
hack-contrib-press.cabal GHC 6.10.4 compatibility (base-4.0) Jul 26, 2009

README.md

Hack.Contrib.Press

Quickstart

Small.hs

{-# LANGUAGE DeriveDataTypeable #-}
{-# OPTIONS -fglasgow-exts #-}

module Main where

import Hack
import Hack.Contrib.Press (renderToResponse)
import Hack.Handler.Happstack (run)
import Text.JSON.Generic

data Profile = Profile {
    name :: String,
    favoriteMusic :: [String]
} deriving (Data, Typeable)

main = run $ \env -> do renderToResponse env "small.html" context
    where aProfile = Profile "Brandon Bickford" ["Rock"]
          context = [toJSON aProfile]

small.html

<html>
    <body>
        <p>
            Hey <b>{{ name }}</b>, I heard you like:
            <ul>
                {% for music in favoriteMusic %}
                    <li>{{ music }}</li>
                {% endfor %}
            </ul>     
        </p>
    </body>
</html>

Run

  • Run: cabal install hack-contrib-press
  • Add "Small.hs" and "small.html"
  • Run: ghc --make -o small Small.hs
  • Run: ./small
  • In your browser visit: http://localhost:3000