# towait

> Towait is a two-way template engine.

Latest version **0.0.3** (published 2021-07-28) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2021-07-28 |
| First published | 2021-04-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 187.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Nakamura |
| Maintainers | ittedev |
| Keywords | template, template-engine, two-way, yaml |

## Links

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

## Alternatives

- [monaco-yaml](https://npm.io/package/monaco-yaml.md) — 420.1K weekly downloads
- [@crewx/workflow](https://npm.io/package/@crewx/workflow.md) — 3.1K weekly downloads
- [yaml-cat](https://npm.io/package/yaml-cat.md) — 38 weekly downloads
- [nunjucks-in-yaml](https://npm.io/package/nunjucks-in-yaml.md) — 9 weekly downloads
- [shopify-symlinks](https://npm.io/package/shopify-symlinks.md) — 3 weekly downloads

## Recent versions

- 0.0.3 (latest) — 2021-07-28
- 0.0.2 — 2021-04-28
- 0.0.1 — 2021-04-27

## README

# towait

A two-way template engine, has 0 or 1 header section and 1 or more bodies. Specifications are currently under development, subject to change in the future.

## Install

```shell
npm install towait
```

## Usage

### JavaScript

```js
const { towait } = require('towait')

// custom filter
towait.let('locale', n => n.toLocaleString())

// Reads data from template and Renders the template with the given data
const email = towait.readFromFile('template.tw', { user: { name: 'Sue', gender: 'woman' }, points: 1000 })
```

### TypeScript

```ts
import { towait } from 'towait'

// custom filter
towait.let('locale', n => n.toLocaleString())

// Reads data from template and Renders the template with the given data
const email = towait.readFromFile('template.tw', { user: { name: 'Sue', gender: 'woman' }, points: 1000 })
```

## Template example

```txt
from: from@mail.address
subject: Welcome to My service

--- html
::: let honorific = switch user.gender
:::   case "man": "Mr."
:::   case "woman": "Ms."
:::   default: "Mx."
::: end
Welcome to My service, {| honorific |} {| user.name |}!

Bonus Points: <b>{| points |> locale |}</b>

<div>
  ::: import 'signature.tw'
</div>
```

## Subset

Towait have a subset for the situation. These are also available in the browser.

### towait/titan

The titan is a template engine that has no data read and import statements.

### towait/tiny

The tiny is a template engine that has no data read, import statements and control syntax.

### towait/t

The t is a minimal template engine with only unhashed inline variables and pipelines.

### towait/y

The y is a data-serialization language similar to YAML but different.

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