|
|
10 месяцев назад | |
|---|---|---|
| .. | ||
| .travis.yml | 10 месяцев назад | |
| LICENSE | 10 месяцев назад | |
| README.md | 10 месяцев назад | |
| index.js | 10 месяцев назад | |
| package.json | 10 месяцев назад | |
| test.js | 10 месяцев назад | |
Expand placeholders in a template string.
$ npm i expand-template -S
Default functionality expands templates using {} as separators for string placeholders.
var expand = require('expand-template')()
var template = '{foo}/{foo}/{bar}/{bar}'
console.log(expand(template, {
foo: 'BAR',
bar: 'FOO'
}))
// -> BAR/BAR/FOO/FOO
Custom separators:
var expand = require('expand-template')({ sep: '[]' })
var template = '[foo]/[foo]/[bar]/[bar]'
console.log(expand(template, {
foo: 'BAR',
bar: 'FOO'
}))
// -> BAR/BAR/FOO/FOO
All code, unless stated otherwise, is dual-licensed under WTFPL and MIT.