# es6-template-string

> Easy and small template engine for the browser and nodejs

Latest version **1.2.0** (published 2020-10-10) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2020-10-10 |
| First published | 2016-08-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | pixcai |
| Maintainers | pixcai |
| Keywords | es6, template |

## Links

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

## Recent versions

- 1.2.0 (latest) — 2020-10-10
- 1.1.0 — 2016-09-01
- 1.0.0 — 2016-08-31

## README

# es6-template-string
Easy and small template engine for the browser and nodejs

[![npm](https://img.shields.io/npm/v/es6-template-string.svg?style=flat-square)](https://www.npmjs.com/package/es6-template-string)
[![npm](https://img.shields.io/npm/dt/es6-template-string.svg?style=flat-square)](https://www.npmjs.com/package/es6-template-string)
[![npm](https://img.shields.io/npm/l/es6-template-string.svg?style=flat-square)](https://www.npmjs.com/package/es6-template-string)

# Install
```shell
npm install --save es6-template-string
```

# API
### render(str[, locals])
Render template `str` with variable `locals`

Example:
```js
var template = require('es6-template-string');

template.render('Node Version: ${ process.version }');
// It equals to
template('Node Version: ${ process.version }');
```

### compile(str)
Compile `str` and return a function that accept one parameters: `locals`

Example:
```js
var template = require('es6-template-string');

var logNodeVersion = template.compile('Node Version: ${ process.version }');
logNodeVersion();
```

# Usage
```js
var template = require('es6-template-string');

// This is hello, world
template('This is ${vars}', {vars: 'hello, world'});

// This is 3
template('This is ${m + n}', {m: 1, n: 2});
// or
var m = 1, n = 2;
template('This is ${m + n}');

var plus = template.compile('This is ${m + n}');
// This is 5
plus({m: 1, n: 4});
```

# License
MIT

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