detemplate
v0.0.1
Published
Parse string by template.
Downloads
3
Maintainers
Readme
detemplate
Parse string by template.
Install
$ npm install --save detemplate
Usage
const detemplate = require('detemplate');
const template = '${name} ${middlename} «${nickname}» ${surname}';
const parseNames = detemplate.compile(template);
parseNames('Bartholomew Jo-Jo «Bart» Simpson');
// Ay, caramba! Eat my shorts!
//
// ➜ {
// name: 'Bartholomew',
// surname: 'Simpson',
// middlename: 'Jo-Jo',
// nickname: 'Bart'
// }
API
compile(template)
Creates a compiled function that can extract data properties from place holders (ES template literal delimiters).
template
Type: string
The string that contains place holders (ES template literal delimiters). These are indicated by the Dollar sign and curly braces (${placeHolder}
).
License
MIT © Andrew Abramov