Integrating Hastache to Scotty
- Scotty - a light-weighted Web framework/router
- Hastache - Haskell implementation of Mustache templates
This is still work-in-progress
{-# 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
- Install Scotty >= 0.5.0. Currently:
$ git clone https://github.com/xich/scotty.git
$ cd scotty
$ cabal install
- Install hastache:
$ cabal install hastache
- Clone & install scotty-hastache
examples
folder- https://gist.github.com/co-dan/6015894