# tplv

> Nano(~170), high performance string template library, based on ES6 String template syntax.

Latest version **1.0.0** (published 2020-03-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install tplv
pnpm add tplv
yarn add tplv
bun add tplv
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-03-19 |
| First published | 2019-12-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 25.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | atool |
| Keywords | template, tplv |

## Links

- npm: https://www.npmjs.com/package/tplv
- npm.io page: https://npm.io/package/tplv

## Recent versions

- 1.0.0 (latest) — 2020-03-19
- 0.2.2 — 2020-02-10
- 0.2.1 — 2020-01-29
- 0.2.0 — 2020-01-21
- 0.1.1 — 2019-12-16
- 0.0.1-beta.1 — 2019-12-11

## README

# TPLV

> Nano(~170b), High performance string template library, based on ES6 String template syntax.

[![npm Version](https://img.shields.io/npm/v/tplv.svg)](https://www.npmjs.com/package/tplv)
[![Build Status](https://github.com/hustcc/tplv/workflows/build/badge.svg)](https://github.com/hustcc/tplv/actions)
[![Coverage Status](https://coveralls.io/repos/github/hustcc/tplv/badge.svg?branch=master)](https://coveralls.io/github/hustcc/tplv?branch=master)
[![npm License](https://img.shields.io/npm/l/tplv.svg)](https://www.npmjs.com/package/tplv)


## Install

```bash
$ npm i --save tplv
```


## Usage

 - `render` template string

```ts
import { render } from 'tplv';

const template = '${ name }, ${value}(${percent} | Top ${array[2]})';

const data = {
  name: 'Hangzhou',
  value: 1200,
  percent: '13%',
  array: [1, 2, 3, 4]
};

render(template, data); // `Hangzhou, 1200(13% | Top 3)` will be got
```

 - `compile` mode

> For 13x faster performance then render mode.

```ts
import { compile } from 'tplv';

const template = '${ name }, ${value}(${percent} | Top ${array[2]})';

const data = {
  name: 'Hangzhou',
  value: 1200,
  percent: '13%',
  array: [1, 2, 3, 4]
};

const fn = compile(template, ['name', 'value', 'percent', 'array']);

fn(data); // `Hangzhou, 1200(13% | Top 3)` will be got
```


## Perf

Run performance test with [rendering-test](https://aui.github.io/art-template/rendering-test/).

![perf test](https://user-images.githubusercontent.com/7856674/74140231-abef9300-4c2f-11ea-875d-d57e845e9ef7.png)


## Dev

```bash
# install dependence
$ npm install

# run test cases
$ npm run test

# run performance for render / compile mode
$ npm run perf

# build package
$ npm run build
```


## License

MIT@[hustcc](https://github.com/hustcc).

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