expand-template

2.0.3 • Public • Published

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.

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i expand-template

    Weekly Downloads

    5,683,714

    Version

    2.0.3

    License

    (MIT OR WTFPL)

    Unpacked Size

    5.41 kB

    Total Files

    6

    Last publish

    Collaborators

    • ralphtheninja