Philipp Horstenkamp f3e1a62935
All checks were successful
Lint / pre-commit Linting (push) Successful in 44s
Dependency update
2025-04-08 22:05:18 +02:00
..
2025-04-08 22:05:18 +02:00
2025-04-08 22:05:18 +02:00
2025-04-08 22:05:18 +02:00
2025-04-08 22:05:18 +02:00
2025-04-08 22:05:18 +02:00

expand-template

Expand placeholders in a template string.

npm Build Status dependencies 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.