Drom_lib.Ez_substSourceEasy Substitutions in Strings
ez_subst provides simple functions to perform substitutions of expressions in strings. By default, expressions are recognized as ${expr} (brace substitution), $(expr) (paren substitution), $[expr] (bracket substitution) and $var (var substitution), but it can be further customized by:
sep (default is '$')sym (default is false, whereas true means '${ident}$'.)Escaping is done using '\\', i.e. any character preceeded by a backslash is printed as itself, and not interpreted as a beginning or ending separator for expression. Escaping can be controled using the escape argument, a reference that can be turned to true or false even during the substitution.
The type for functions performing the translation from ident to its replacement. 'context is some information, that is from the initial call to the substitution.
The only exception that may be raised by substitutions: it indicates that the end of the expression could not be found.
val string :
?sep:char ->
?sym:bool ->
?escape:bool ref ->
?brace:'context t ->
?paren:'context t ->
?bracket:'context t ->
?var:'context t ->
'context ->
string ->
stringstring f context s performs substitutions on s following f, passing the context context to f for every expression, returning the result as a string.
val buffer :
?sep:char ->
?sym:bool ->
?escape:bool ref ->
?brace:'context t ->
?paren:'context t ->
?bracket:'context t ->
?var:'context t ->
Buffer.t ->
'context ->
string ->
unitbuffer f b context s performs substitutions on s following f, passing the context context to f for every expression, returning the result by appending it to the buffer b.