/scotty-hastache

Integrating Hastache to Scotty

Primary LanguageHaskellBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

scotty-hastache

Integrating Hastache to Scotty

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>

Installation

  1. Install GHC, Haskell platform, etc
  2. Install Scotty >= 0.5.0. Currently:
$ git clone https://github.com/xich/scotty.git
$ cd scotty
$ cabal install
  1. Install hastache:
$ cabal install hastache
  1. Clone & install scotty-hastache

Examples