https://github.com/mrmlnc/expand-placeholder
📦 Takes a string and interpolates the values.
https://github.com/mrmlnc/expand-placeholder
expand interpolation placeholder string string-manipulation
Last synced: 6 months ago
JSON representation
📦 Takes a string and interpolates the values.
- Host: GitHub
- URL: https://github.com/mrmlnc/expand-placeholder
- Owner: mrmlnc
- License: mit
- Created: 2016-11-15T00:29:58.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-11-19T14:40:29.000Z (over 8 years ago)
- Last Synced: 2025-08-31T11:15:13.331Z (11 months ago)
- Topics: expand, interpolation, placeholder, string, string-manipulation
- Language: JavaScript
- Homepage:
- Size: 39.1 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# expand-placeholder
> Takes a string and interpolates the values.
[](https://travis-ci.org/mrmlnc/expand-placeholder)
## Install
```shell
$ npm i -S expand-placeholder
```
## Why?
* Dependencies free.
* Very fast.
* Sufficiently flexible.
## Usage
```js
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!
```
## API
### expandPlaceholder(source, data, [options])
Takes a string and interpolates the values.
#### source
* Type: `String`
A string for processing.
#### data
* Type: `Object`
Data for the interpolation.
#### Options
* Type: `Object`
```js
{
// 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
}
```
## Changelog
See the [Releases section of our GitHub project](https://github.com/mrmlnc/expand-placeholder/releases) for changelogs for each release version.
## License
This software is released under the terms of the MIT license.