# taya

> JavaScript beautiful template engine

Latest version **3.0.0** (published 2015-10-28) · MIT license · 0 weekly downloads

## Install

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

Provides the command `taya`.

## 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 | 3.0.0 |
| Published | 2015-10-28 |
| First published | 2015-09-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Advancid |
| Maintainers | advancid |
| Keywords | advancid, template, engine, render |

## Links

- npm: https://www.npmjs.com/package/taya
- Repository: https://github.com/advancid/taya
- Homepage: https://github.com/advancid/taya#readme
- Issues: https://github.com/advancid/taya/issues
- npm.io page: https://npm.io/package/taya

## Dependencies (2)

- [mz](https://npm.io/package/mz.md) ^2.1.0
- [html-entities](https://npm.io/package/html-entities.md) ^1.2.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2015-10-28
- 2.1.0 — 2015-10-24
- 2.0.0 — 2015-10-09
- 1.0.2 — 2015-09-30
- 1.0.1 — 2015-09-25
- 1.0.0 — 2015-09-24
- 0.0.4 — 2015-09-13
- 0.0.3 — 2015-09-13
- 0.0.2 — 2015-09-11
- 0.0.1 — 2015-09-11

## README

# Taya

## Presentation

Taya is a JavaScript fast and beautiful engine.

Here is an example.

```
@each (user in users)
	{ user.name }

	@if (user.publishEmail)
		{ user.email }
	@end
@end
```

## Syntax

The syntax is very simple.

#### Condition

```
@if (condition)

@elif (anotherCondition)

@else

@end
```

```
@unless (condition)

@else

@end
```

#### Foreach loop

```
@each (value in list)
	{ value.thing }
@end
```

#### Execute

```
@execute (result = 'test')
```

#### Print

```
{ Math.random() }
```

#### Escape

```
!@escaped
!{ also }
```

## API

First, install the NPM package:
`npm install taya`

### Taya

The Taya class represents a template.

```
import Taya from 'taya';

let template = new Taya('{{ hello }}');
```

##### Taya#render([context, escape])

Renders a Taya template with a context, and the escape function.

By default, context is an empty object, and escape is an HTML escape function.

```
import Taya from 'taya';

let template = new Taya('{{ hello }}');

template.render({
	hello: 'Hello World'
}) === 'Hello World';
```

##### Taya.render(source, [context, escape])

Render a taya source with a context and an escape function.
See above for the parameters.

##### Taya.renderFile(path, [context, escape])

Renders a taya file (use a cache) and return a promise.
See above for context and escape parameters.

```
import Taya from 'taya';

Taya.renderFile('test.tay').then(function(result) {
	console.log(result);
});
```

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