0.0.4 • Published 8 years ago

small-supplant v0.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

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