{-# 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>
The Tidelift Subscription provides access to a continuously curated stream of human-researched and maintainer-verified data on open source packages and their licenses, releases, vulnerabilities, and development practices.