15270821319 4e5c5d37f9 初步设计数据库,注册登录 10 mēneši atpakaļ
..
.travis.yml 4e5c5d37f9 初步设计数据库,注册登录 10 mēneši atpakaļ
LICENSE 4e5c5d37f9 初步设计数据库,注册登录 10 mēneši atpakaļ
README.md 4e5c5d37f9 初步设计数据库,注册登录 10 mēneši atpakaļ
index.js 4e5c5d37f9 初步设计数据库,注册登录 10 mēneši atpakaļ
package.json 4e5c5d37f9 初步设计数据库,注册登录 10 mēneši atpakaļ
test.js 4e5c5d37f9 初步设计数据库,注册登录 10 mēneši atpakaļ

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.