templater: Simple string templater

[ library, mit, text ] [ Propose Tags ]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.0.2.0, 0.0.3.0
Dependencies attoparsec (>=0.12), base (>=4.5 && <4.9), text (>=1.1) [details]
License MIT
Author Geraud Boyer
Maintainer geraud@gmail.com
Category Text
Home page https://github.com/geraud/templater
Uploaded by geraud at 2015-04-29T01:40:27Z
Distributions NixOS:0.0.3.0
Reverse Dependencies 1 direct, 1 indirect [details]
Downloads 1512 total (13 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-04-29 [all 1 reports]

Readme for templater-0.0.2.0

[back to package description]

Templater

Build Status

Simple string templater

Installation

cabal update
cabal install templater

Example

{-# LANGUAGE OverloadedStrings #-}
import           Data.Text
import qualified Data.Text.IO   as TIO
import           Text.Templater

main :: IO ()
main = do
  let textTemplate = "Hello, %{what is it ?}!"
      res = template textTemplate context
  case res of
    Left error -> do
        putStrLn $ "Got Error:" ++ error
    Right result -> TIO.putStrLn result

context :: Context -- Context is a type alias for Text -> Maybe Text
context "what is it ?" = Just "world"
context _ = Nothing

renders to Hello, world!

Well that's all there is to it!...