Description
render hastache templates using aeson values.
Description
The Module lets you render Hastache templates from aeson values. See the GitHub page for examples.
README.md
hastache-aeson
- Lets you pass aeson
Value
asMuContext
to hastache - Since yaml is API-compatible to
aeson
, you can also renderyaml Value
s.
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.