🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

expand-template

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expand-template

Expand placeholders in a template string

latest
Source
npmnpm
Version
2.0.3
Version published
Weekly downloads
15M
-2.78%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

template

FAQs

Package last updated on 27 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts