世祺 0423d5801c Initial commit (by Create-Cloudflare CLI) 1 年間 前
..
.travis.yml 0423d5801c Initial commit (by Create-Cloudflare CLI) 1 年間 前
LICENSE 0423d5801c Initial commit (by Create-Cloudflare CLI) 1 年間 前
README.md 0423d5801c Initial commit (by Create-Cloudflare CLI) 1 年間 前
index.js 0423d5801c Initial commit (by Create-Cloudflare CLI) 1 年間 前
package.json 0423d5801c Initial commit (by Create-Cloudflare CLI) 1 年間 前
test.js 0423d5801c Initial commit (by Create-Cloudflare CLI) 1 年間 前

README.md

expand-template

Expand placeholders in a template string.

npm Node version Build Status JavaScript Style Guide

Install

$ npm i expand-template -S

Usage

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

License

All code, unless stated otherwise, is dual-licensed under WTFPL and MIT.