heystreamer/node_modules/expand-template
Bashy 6c7facadce
Some checks failed
CI / check (push) Has been cancelled
rework
2026-04-26 23:00:55 +03:00
..
.travis.yml rework 2026-04-26 23:00:55 +03:00
index.js rework 2026-04-26 23:00:55 +03:00
LICENSE rework 2026-04-26 23:00:55 +03:00
package.json rework 2026-04-26 23:00:55 +03:00
README.md rework 2026-04-26 23:00:55 +03:00
test.js rework 2026-04-26 23:00:55 +03: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.