expand-template

Expand placeholders in a template string

(MIT OR WTFPL) 11 个版本
安装
npm install expand-template
yarn add expand-template
pnpm add expand-template
bun add expand-template
README

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.

版本列表
2.0.3 2018-11-27
2.0.2 2018-11-27
2.0.1 2018-11-20
2.0.0 2018-06-21
1.1.1 2018-05-07
1.1.0 2017-08-22
1.0.4 2017-08-22
1.0.3 2016-09-14
1.0.2 2015-11-12
1.0.1 2015-10-28
1.0.0 2015-08-10