hastache-aeson: render hastache templates using aeson values

[ bsd3, library, text ] [ Propose Tags ]

The Module lets you render Hastache templates from aeson values. See the GitHub page for examples.

[Skip to Readme]




Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],
Dependencies aeson (>=, base (>=4.6 && <5), bytestring (>=0.10), containers (>=0.5), hastache (>=0.5), scientific (>=0.2), text (>=0.11), unordered-containers (>=0.2), vector (>=0.10) [details]
License BSD-3-Clause
Copyright Vladimir Kirillov
Author Vladimir Kirillov <proger@hackndev.com>
Maintainer Vladimir Kirillov <proger@hackndev.com>
Category Text
Home page https://github.com/proger/hastache-aeson
Bug tracker https://github.com/proger/hastache-aeson/issues
Source repo head: git clone git://github.com/proger/hastache-aeson.git
Uploaded by VladimirKirillov at 2015-09-11T10:34:43Z
Reverse Dependencies 2 direct, 0 indirect [details]
Downloads 1691 total (7 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2015-09-11 [all 1 reports]

Readme for hastache-aeson-

[back to package description]


Build Status

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


{-# 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


  • Viktar Basharymau
  • Vladimir Kirillov