# stml

> Lightweight JavaScript template engine.

Latest version **1.0.1** (published 2017-03-03) · MIT license · 0 weekly downloads

## Install

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

## 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 | 1.0.1 |
| Published | 2017-03-03 |
| First published | 2017-03-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Chikara Chan |
| Maintainers | chikara |
| Keywords | template, engine |

## Links

- npm: https://www.npmjs.com/package/stml
- Repository: https://github.com/chikara-chan/stml
- Issues: https://github.com/chikara-chan/stml/issues
- npm.io page: https://npm.io/package/stml

## Dependencies (1)

- [invincible](https://npm.io/package/invincible.md) ^1.3.0

## Recent versions

- 1.0.1 (latest) — 2017-03-03
- 1.0.0 — 2017-03-03

## README

# Super Type Markup Language

Lightweight JavaScript template engine for better cleaner code.

[![Travis branch](https://img.shields.io/travis/chikara-chan/stml/master.svg)](https://travis-ci.org/chikara-chan/stml)
[![Coveralls branch](https://img.shields.io/coveralls/chikara-chan/stml/master.svg)](https://coveralls.io/github/chikara-chan/stml)
[![npm](https://img.shields.io/npm/v/stml.svg)](https://www.npmjs.com/package/stml)
[![npm](https://img.shields.io/npm/l/stml.svg)](https://github.com/chikara-chan/stml/blob/master/LICENSE)

## Install

``` bash
$ npm install stml
# Or
$ yarn add stml
```

## Usage

``` js
import fs from 'fs'
import path from 'path'
import stml from 'stml'

const src = fs.readFileSync(path.join(__dirname, 'template.html'))
const dest = stml.compile(src, {
  locals: {
    entries: ['James', 'John', 'Tom']
  },
  filename: path.join(__dirname, 'template.html')
})

console.log(dest)
```

## API

Name | Type | Default | Description
--- | --- | --- | ---
locals | Object |  | The options to pass params to template.
filename | String |  | The absolute path souce filename when extends is declared.
expressionOpen | String | '{' | Expression statement open syntax.
expressionClose | String | '}' | Expression statement close syntax.
blockOpen | String | '<%' | Block statement open syntax.
blockClose | String | '%>' | Block statement close syntax.

## Syntax

#### expression statement

Use jsx syntax for expression statement.
``` html
<div>{ name }</div> <!-- escape -->
<div>{- name }</div> <!-- unescape -->
```

#### block statement

Use jsp syntax for block statement.
``` html
<% if (entries.length) { %>
  <ul>
    <% entries.forEach(function(entry){ %>
      <li>{ entry }</li>
    <% }) %>
  </ul>
<% } %>

```

#### extends statement

Use jsp syntax for extends statement.
``` html
<% extends 'header.html' %>

```

## License

Released under the [MIT](https://github.com/chikara-chan/stml/blob/master/LICENSE) license.

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