I am happy to announce the first release of the scotty-hastache library. The purpose of this library is to use the light templating language Mustache together with the Scotty web framework. This is done by enriching the ActionM DSL with additional commands.
Example code:
{-# 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"
This is possible due to the recent changes introduced into the latest scotty-0.5 release, in particular the switch to monad transformers. You can read the scotty-0.5 release notes here.
The scotty-hastache library is available on Hackage and on GitHub