@hackage hastache-aeson0.1.1.0

render hastache templates using aeson values

hastache-aeson

Build Status

  • Lets you pass aeson Value as MuContext to hastache
  • Since yaml is API-compatible to aeson, you can also render yaml Values.

Example

{-# LANGUAGE OverloadedStrings #-}

import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as LBS

import Control.Monad
import Data.Maybe (fromJust)

import Data.Yaml
import Text.Hastache
import Text.Hastache.Aeson (jsonValueContext)

event = BS.readFile "event.yaml"
template = BS.readFile "index.mustache"

render template value = hastacheStr defaultConfig template (jsonValueContext value)

main = do
    value <- liftM (fromJust . decode) event :: IO Value
    template' <- template
    render template' value >>= LBS.putStrLn

Contributors

  • Viktar Basharymau
  • Vladimir Kirillov