# jemplator

> Read and fill template files.

Latest version **1.2.3** (published 2019-11-12) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.2.3 |
| Published | 2019-11-12 |
| First published | 2019-11-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 11.6 KB |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | jdeurt |

## Links

- npm: https://www.npmjs.com/package/jemplator
- Repository: https://github.com/jdeurt/node-jemplator
- Homepage: https://github.com/jdeurt/node-jemplator#readme
- Issues: https://github.com/jdeurt/node-jemplator/issues
- npm.io page: https://npm.io/package/jemplator

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [safe-eval](https://npm.io/package/safe-eval.md) ^0.4.1

## Recent versions

- 1.2.3 (latest) — 2019-11-12
- 1.2.2 — 2019-11-12
- 1.2.1 — 2019-11-12
- 1.2.0 — 2019-11-12
- 1.1.0 — 2019-11-11

## README

# Jemplator
Read and fill template files.

### Instalation

```shell
$ npm i jemplator
```

### Examples

#### Filling a template file

##### Template file

```
A simple sentence:
Hello my name is {{ user.name }} and I am a(n) {{ user.age }} year-old {{ user.gender }}!

Inline sandboxed Javascript execution:
{{>> js {{ numbers }}.join(", ") }}

Yes, {{ numbers }} gets stringified.
```

##### Javascript

```javascript
const Jemplator = require("jemplator");

// Update the output file manually like this or you can pass true as the last
// parameter to have it automatically update every time it's filled.
const template = new Jemplator("./input.template", "./output.txt");

template.fill({
  user: {
    name: "Juan de Urtubey",
    age: 18,
    gender: "male"
  },
  numbers: [1, 2, 3]
});

template.update();
```

##### Output

```
A simple sentence:
Hello my name is Juan de Urtubey and I am a(n) 18 year-old male!

Inline sandboxed Javascript execution:
1, 2, 3

Yes, [1,2,3] gets stringified.
```

#### Filling a template string

```javascript
const Jemplator = require("jemplator");

const templateString = "{{ greeting }} {{ user.name }}{{>> js '!' }}";

console.log(Jemplator.fillStr(templateString, {
  greeting: "Hello",
  user: {
    name: "Bob"
  }
}));

// "Hello Bob!"
```

### License

This project is licensed under the MIT License

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