fillit-0.1.0.0: Flexible string substitution

Safe HaskellNone
LanguageHaskell2010

Data.Text.Fillit

Synopsis

Documentation

data Config Source #

Constructors

Config 

Instances

def :: Default a => a #

The default value for this type.

fill :: Template -> Dict -> Either String Text Source #

>>> fill "Hi, $name$" dic
Right "Hi, Tom"
>>> fill "$date$: %note%" dic
Right "2017-08-01 12:00: %note%"
>>> fill "%date% $name$" dic
Right "2017-08-01 12:00 Tom"
>>> fill "$name$ ($age$)" dic
Left ...

fill' :: Config -> Template -> Dict -> Either String Text Source #

>>> :{
  let config = Config { reqFrom = "<<"
                      , reqTo   = ">>"
                      , optFrom = "{{"
                      , optTo   = "}}"
                      }
  in fill' config "Hi, <<name>>" dic
:}
Right "Hi, Tom"