https://github.com/felippemauricio/string-interpolation-parser
Dynamic string manipulation
https://github.com/felippemauricio/string-interpolation-parser
dynamic interpolation replace replace-text string string-manipulation
Last synced: 9 months ago
JSON representation
Dynamic string manipulation
- Host: GitHub
- URL: https://github.com/felippemauricio/string-interpolation-parser
- Owner: felippemauricio
- License: mit
- Created: 2019-04-23T02:13:56.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T20:16:36.000Z (about 3 years ago)
- Last Synced: 2025-06-08T18:05:38.956Z (10 months ago)
- Topics: dynamic, interpolation, replace, replace-text, string, string-manipulation
- Language: JavaScript
- Homepage: https://bit.ly/2Vp6HQO
- Size: 325 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# String Interpolation {{ HelloWorld }}
[](https://github.com/felippemauricio/string-interpolation-parser/blob/master/LICENSE.md)
[](https://www.npmjs.com/package/string-interpolation-parser)
[](https://travis-ci.org/felippemauricio/string-interpolation-parser)
[](https://david-dm.org/felippemauricio/string-interpolation-parser?type=dev)
[](https://coveralls.io/github/felippemauricio/string-interpolation-parser?branch=master)
[](https://github.com/airbnb/javascript)
[](https://github.com/felippemauricio/string-interpolation-parser/pulls)
This package assists with dynamic string interpolation and on the fly value transformation.
## Installation
Using yarn:
```js
yarn add string-interpolation-parser
```
Using npm:
```js
npm i --save string-interpolation-parser
```
## Usage
```js
import parser from 'string-interpolation-parser';
const params = {
param1: 'Welcome, {{ vendor.name }}',
param2: 'Welcome the {{ store.data.name }}, Sr. {{ customer }}',
param3: 10,
param4: true,
param5: null,
param6: undefined,
param7: 'Hello World',
param8: '{{var1}}, {{var2}}',
};
const context = {
vendor: {
name: 'Felippe Maurício',
},
store: {
data: {
address: 'RJ',
name: 'Rio de Janeiro',
},
},
customer: 'Luciana Cabral',
var1: 'Hello',
var2: 'World',
};
const result = parser(params, context);
console.log('result = ', result)
// result = {
// param1: 'Welcome, Felippe Maurício',
// param2: ''Welcome the Rio de Janeiro, Sr. Luciana Cabral',
// param3: 10,
// param7: 'Hello World',
// param8: 'Hello, World',
// }
```
## API
```js
parser(params : Object, context : Object) => Object
```
## License
Licensed under the MIT License, Copyright © 2019-present Felippe Maurício.