small-supplant

Small supplant for template strings

Usage no npm install needed!

<script type="module">
  import smallSupplant from 'https://cdn.skypack.dev/small-supplant';
</script>

README

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