shellsubstitute
Like shell substitution but for your JS.
Last updated 10 years ago by refractalize .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ npm install shellsubstitute 
SYNC missed versions from official npm registry.

Shell Substitute npm version npm Build Status

Like shell substitution but for your JS.

var substitute = require('shellsubstitute');

substitute('Hi $USER', {USER: 'Josh'}) // Hi Josh
substitute('Hi ${USER}', {USER: 'Josh'}) // Hi Josh

// escape
substitute('Hi \\$USER', {USER: 'Josh'}) // Hi $USER
substitute('Hi \\${USER}', {USER: 'Josh'}) // Hi ${USER}

// escape escapes
substitute('Hi \\\\$USER', {USER: 'Josh'}) // Hi \$USER
substitute('Hi \\\\${USER}', {USER: 'Josh'}) // Hi \${USER}

Syntax

Variables are $ followed by _ or numbers 0-9 or upper or lower-case characters a-z.

Variables can be wrapped in braces {...}. Useful to delimit the variable from following text.

Current Tags

  • 1.2.0                                ...           latest (8 years ago)

3 Versions

  • 1.2.0                                ...           8 years ago
  • 1.1.0                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Total 1
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE