世祺 0423d5801c Initial commit (by Create-Cloudflare CLI) | 1 rok pred | |
---|---|---|
.. | ||
.travis.yml | 1 rok pred | |
LICENSE | 1 rok pred | |
README.md | 1 rok pred | |
index.js | 1 rok pred | |
package.json | 1 rok pred | |
test.js | 1 rok pred |
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
.