Skip to content

Simple library to substitute variables into strings

Notifications You must be signed in to change notification settings

nicomt/varsubst

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

varsubst

Simple library to substitute variables into strings

Install

Install with npm:

$ npm install varsubst

Usage

The API is simple

const varsubst = require('varsubst')

varsubst('hello $var', { var: 'world' })              // hello world
varsubst('inThe${var}OfText', { var: 'Middle' })      // inTheMiddleOfText
varsubst('escaping $${var}', { var: 'noop' })         // escaping ${var}
varsubst('using ${var:-default}', {})                 // using default
varsubst('using ${none:-$var} vars', {var: 'nested'}) // using nested vars
varsubst('${USER} is substituting env', process.env)  // <user> is substituting env

About

Simple library to substitute variables into strings

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published