string-template-parser
String template parsing utilities.
parseStringTemplate
uses the default configuration (i.e. variable
start is marked by ${
and variable end by }
, the escape character
is \
, a pipe is started with |
and a pipe parameter starts after
a :
, e.g. 'string ${var | pipe : parameter}'
).
parseStringTemplateGenerator
returns a string parsing function
that uses the supplied expressions from the configuration parameter
to parse the string.
Usage
parseStringTemplate
import { parseStringTemplate } from 'string-template-parser';
parseStringTemplate('a ${v1|p:param} b ${v2} c');
parseStringTemplateGenerator
import { parseStringTemplateGenerator } from 'string-template-parser';
const myParseStringTemplate = parseStringTemplateGenerator({VARIABLE_START: /^\{\{/, VARIABLE_END: /^\}\}/});
myParseStringTemplate('a {{v1|p:param}} b {{v2}} c');