Integrating Hastache into Scotty
- Scotty - a light-weighted Web framework/router
- Hastache - Haskell implementation of Mustache templates
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Text.Hastache
import Web.Scotty.Trans as S
import Web.Scotty.Hastache
main :: IO ()
main = scottyH' 3000 $ do
setTemplatesDir "templates"
-- ^ Setting up the director with templates
get "/:word" $ do
beam <- param "word"
setH "action" $ MuVariable (beam :: String)
-- ^ "action" will be binded to the contents of 'beam'
hastache "greet.html"
templates/greet.html:
<h1>Scotty, {{action}} me up!</h1>
- Install GHC, Haskell platform, etc.
- Use cabal-install to automatically pull all the dependencies and install the library:
cabal update
cabal install scotty-hastache
examples
folder- https://gist.github.com/co-dan/6015894