# interpolate-string

> Simple string interpolation without dependencies.

Latest version **1.3.0** (published 2019-05-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install interpolate-string
pnpm add interpolate-string
yarn add interpolate-string
bun add interpolate-string
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2019-05-23 |
| First published | 2019-02-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | László Bulik |
| Maintainers | lionel87 |
| Keywords | string interpolation, variable interpolation, variable substitution, variable expansion |

## Links

- npm: https://www.npmjs.com/package/interpolate-string
- Repository: https://github.com/lionel87/interpolate-string
- Homepage: https://github.com/lionel87/interpolate-string#readme
- Issues: https://github.com/lionel87/interpolate-string/issues
- npm.io page: https://npm.io/package/interpolate-string

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.3.0 (latest) — 2019-05-23
- 1.2.0 — 2019-04-23
- 1.1.0 — 2019-04-23
- 1.0.1 — 2019-02-08
- 1.0.0 — 2019-02-08

## README

# String interpolation
Replaces the marked parts of a text with values from a given set, similar to a templating engine, but less robust.

## Installation
```
npm install --save interpolate-string
```

## Usage
```js
const interpolate = require("interpolate-string");

const text = "Hello {{ name.first }}!";
const data = { name: { first: "John", last: "Doe" }};

const result = interpolate(text, data);

console.log(result); // Hello John!
```

Alternatively you can also specify a pattern for the replacement format:

```js
const interpolate = require("interpolate-string");

const text = "Hello ${name.first}!";
const pattern = /\$\{(.+?)\}/g;
const data = { name: { first: "John", last: "Doe" }};

const result = interpolate(text, data, pattern);

console.log(result); // Hello John!
```

---
_Source: https://npm.io/package/interpolate-string · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
