volleyball-dev-frontend/node_modules/expand-template
Marc Wieland 33181acf83
Some checks are pending
Deploy Volleyball CMS / deploy (push) Waiting to run
Last
2025-06-02 18:56:22 +02:00
..
.travis.yml Last 2025-06-02 18:56:22 +02:00
index.js Last 2025-06-02 18:56:22 +02:00
LICENSE Last 2025-06-02 18:56:22 +02:00
package.json Last 2025-06-02 18:56:22 +02:00
README.md Last 2025-06-02 18:56:22 +02:00
test.js Last 2025-06-02 18:56:22 +02:00

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.