small-supplant

0.0.4 • Public • Published

small-supplant

Build Status npm version JavaScript Style Guide

Small module that does variable replacement in strings:

supplant('Hello, {{ name }}!', {name: 'John'})
// Hello, John

It also supports deep properties:

supplant('Full name: {{person.first_name}} {{person.last_name}}', {
  person: {
    first_name: 'Peter',
    last_name: 'Parker'
  }
})
 
// Full name: Peter Parker

and custom delimiters:

supplant.delimiters = ['${', '}']
supplant('<p>${text}</p>', text: 'Nice!') // <p>Nice!</p>
 
supplant.delimiters = ['<?=', '?>']
supplant('I love <?= language ?>!', {language: 'PHP'}) // I love PHP!

And nothing else. Just it!

installation

npm install small-supplant --save

For browsers, you can copy the small-supplant.browser.js in the browser folder, and include it into your page.

tests

npm install && npm test

browser support

+IE9 ✔

license

MIT

Package Sidebar

Install

npm i small-supplant

Weekly Downloads

2

Version

0.0.4

License

MIT

Last publish

Collaborators

  • gsantiago