The fillit package

[ Tags: bsd3, library, text ] [ Propose Tags ]

Please see README.md


[Skip to Readme]

Properties

Versions 0.1.0.0
Dependencies base (>=4.7 && <5), data-default, parsec, text, unordered-containers [details]
License BSD3
Copyright (c) 2017 ishiy
Author ishiy <y.ishihara.1993@gmail.com>
Maintainer ishiy <y.ishihara.1993@gmail.com>
Category Text
Home page https://github.com/ishiy1993/fillit#readme
Uploaded Wed Sep 6 21:17:12 UTC 2017 by ishiy
Distributions NixOS:0.1.0.0
Downloads 168 total (8 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-09-06 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for fillit-0.1.0.0

[back to package description]

fillit

Flexible String Substitution library

Features

  • Support two kinds of substitutions: required and optional.
  • You can change the symbols for substitutions.

Note: This library does not support any sanitization.

Usage

Example:

ghci> :set -XOverloadedStrings
ghci> import Data.Text.Fillit
ghci> import qualified Data.HashMap.Lazy as HM
ghci> let dic = HM.fromList [("name", "Tom"), ("age", "22")]
ghci> fill "$name$ (%age%)" dic
Right "Tom (22)"
ghci> fill "$name$ (%school%)" dic
Right "Tom (%school%)"
ghci> fill "$name$ ($school$)" dic
Left "There is no key in dict, such as school"

By default, the symbol $ means a required substitution. On the other hand, the symbol % means a optional substitution. These symbols can be changed. See fill'.

Development

$ git clone git@github.com:ishiy1993/fillit.git
$ cd fillit
$ stack build
$ stack test