# string-template-js

> String-templating utility that creates new string literals based on templates and embedded expressions (or values).

Latest version **1.0.3** (published 2019-07-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install string-template-js
pnpm add string-template-js
yarn add string-template-js
bun add string-template-js
```

## 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.0.3 |
| Published | 2019-07-01 |
| First published | 2017-11-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Lucian Vuc |
| Maintainers | lucivuc |
| Keywords | string template, template, string template literal |

## Links

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

## 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.0.3 (latest) — 2019-07-01
- 1.0.2 — 2018-02-26
- 1.0.1 — 2018-02-24
- 1.0.0 — 2017-11-10

## README

# string-template-js

## Description 

String templating utility that creates new string literals based on templates and embedded expressions (or values). A template is given as a string, which similar to the `ES6 Literal Templates` contains placeholders that will be replaced with actual values or expressions, whereas the actual values or expressions are given as properties of a JS object (a hashmap of key-value pairs). A placeholder is an identifier enclosed within curly braces and preceded by the 'Dollar' sign (`${expression}`), which is expected to match the reference to the actual value or expression.

## Usage

### `replace (sTemplate, mData)`

#### Parameters:

Name	| Type	| Description
------|-------|-------------
`sTemplate`	| `String`	| The string template, which, similar to the ES6 literal templates can contain value placeholders enclosed within curly braces and preceded by the 'Dollar' sign (`${expression}`)
`mData`	| `Object`	| The JS object (hashmap) containing the actual values and expressions to replace the template placeholders with.

#### Returns:
Type: `String`


## Examples

```js
var stringTemplate = require("string-template-js");

// the actual value is a string
stringTemplate.replace("Hello ${value}!", { value: "world" }); // "Hello world!"

// if the actual value is a function, it will be evaluated
stringTemplate.replace("Hello ${value}!", { value: function() { return "world"; } }); // "Hello world!"
```

## Installation

`npm install string-template-js`

## Version

1.0.3

## License

MIT

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