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]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.1.0
Dependencies aeson (>=0.6 && <0.7), attoparsec (>=0.10 && <0.11), base (>=4.6 && <4.7), bytestring (>=0.10 && <0.11), containers (>=0.5 && <0.6), hastache (>=0.5 && <0.6), text (>=0.11 && <0.12), unordered-containers (>=0.2 && <0.3), vector (>=0.10 && <0.11) [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 2013-07-12T18:11:31Z
Distributions
Reverse Dependencies 2 direct, 0 indirect [details]
Downloads 1700 total (3 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for hastache-aeson-0.1.0.0

[back to package description]

hastache-aeson

  • 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

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.