The hastache-aeson package

[Tags: bsd3, library]

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


[Skip to ReadMe]

Properties

Version0.1.0.0
Change logNone available
Dependenciesaeson (==0.6.*), attoparsec (==0.10.*), base (==4.6.*), bytestring (==0.10.*), containers (==0.5.*), hastache (==0.5.*), text (==0.11.*), unordered-containers (==0.2.*), vector (==0.10.*) [details]
LicenseBSD3
CopyrightVladimir Kirillov
AuthorVladimir Kirillov <proger@hackndev.com>
MaintainerVladimir Kirillov <proger@hackndev.com>
CategoryText
Home pagehttps://github.com/proger/hastache-aeson
Bug trackerhttps://github.com/proger/hastache-aeson/issues
Source repositoryhead: git clone git://github.com/proger/hastache-aeson.git
UploadedFri Jul 12 18:11:31 UTC 2013 by VladimirKirillov
Downloads233 total (14 in last 30 days)
Votes
0 []
StatusDocs uploaded by user
Build status unknown [no reports yet]

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for hastache-aeson-0.1.0.0

hastache-aeson

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

BSD3 License

Copyright (c) 2013 Vladimir Kirillov

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

3. Neither the name of the author nor the names of his contributors
   may be used to endorse or promote products derived from this software
   without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.