expand-template
Expand placeholders in a template string
Last updated 9 years ago by ralphtheninja .
WTFPL · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install expand-template 
SYNC missed versions from official npm registry.

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.

Current Tags

  • 2.0.3                                ...           latest (6 years ago)

11 Versions

  • 2.0.3                                ...           6 years ago
  • 2.0.2                                ...           6 years ago
  • 2.0.1                                ...           6 years ago
  • 2.0.0                                ...           6 years ago
  • 1.1.1                                ...           6 years ago
  • 1.1.0                                ...           7 years ago
  • 1.0.4                                ...           7 years ago
  • 1.0.3                                ...           8 years ago
  • 1.0.2                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (0)
None

Copyright 2013 - present © cnpmjs.org | Home |