Takes a string and interpolates the values.
$ npm i -S expand-placeholder
- Dependencies free.
- Very fast.
- Sufficiently flexible.
const expandPlaceholder = require('expand-placeholder');
const str = 'Hello from {{ country }}!';
const data {
country: 'Russia'
}
const expanded = expandPlaceholder(str, data);
console.log(expanded);
// => Hello from Russia!
Takes a string and interpolates the values.
- Type:
String
A string for processing.
- Type:
Object
Data for the interpolation.
- Type:
Object
{
// String. Characters that define the beginning of a placeholder.
opening: '{{',
// String. Characters that define the end of a placeholder.
closing: '{{',
// Function. Allows to change a value before the insert into string.
transformValue: (val) => val
}
See the Releases section of our GitHub project for changelogs for each release version.
This software is released under the terms of the MIT license.