https://github.com/proger/hastache-aeson
Aeson support for Hastache
https://github.com/proger/hastache-aeson
Last synced: 8 months ago
JSON representation
Aeson support for Hastache
- Host: GitHub
- URL: https://github.com/proger/hastache-aeson
- Owner: proger
- License: other
- Created: 2013-07-12T17:48:12.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2015-09-14T07:15:53.000Z (almost 11 years ago)
- Last Synced: 2025-10-21T13:49:20.105Z (8 months ago)
- Language: Haskell
- Homepage: http://hackage.haskell.org/package/hastache-aeson
- Size: 197 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
hastache-aeson
==============
[](https://travis-ci.org/proger/hastache-aeson)
* Lets you pass [aeson](http://hackage.haskell.org/package/aeson) `Value` as `MuContext` to [hastache](http://hackage.haskell.org/package/hastache)
* Since [yaml](http://hackage.haskell.org/package/yaml) is API-compatible to `aeson`, you can also render `yaml` `Value`s.
Example
-------
```haskell
{-# 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