# @blueprod/ws-view-koa-ejs

> ejs render middleware for koa

Latest version **0.1.0** (published 2019-07-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @blueprod/ws-view-koa-ejs
pnpm add @blueprod/ws-view-koa-ejs
yarn add @blueprod/ws-view-koa-ejs
bun add @blueprod/ws-view-koa-ejs
```

## 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.1.0 |
| Published | 2019-07-16 |
| First published | 2019-07-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | thanhlq |
| Maintainers | vudv, thanhlq |
| Keywords | koa, render, ejs, view |

## Links

- npm: https://www.npmjs.com/package/@blueprod/ws-view-koa-ejs
- Repository: https://github.com/EMSA-TECHNOLOGY/blueprod
- Homepage: https://github.com/EMSA-TECHNOLOGY/blueprod/packages/ws-view-koa-ejs
- Issues: https://github.com/EMSA-TECHNOLOGY/blueprod/issues
- npm.io page: https://npm.io/package/@blueprod/ws-view-koa-ejs

## Dependencies (3)

- [mz](https://npm.io/package/mz.md) ^2.7.0
- [ejs](https://npm.io/package/ejs.md) ^2.6.2
- [debug](https://npm.io/package/debug.md) ^4.1.1

## Recent versions

- 0.1.0 (latest) — 2019-07-16

## README

ws-view-koa-ejs
================

Koa ejs view render middleware. support all feature of [ejs](https://github.com/mde/ejs).

(Ref: https://github.com/koajs/ejs)

## Usage

### Example

```js
const Koa = require('koa');
const render = require('@blueprod/ws-view-koa-ejs');
const path = require('path');

const app = new Koa();
render(app, {
  root: path.join(__dirname, 'view'),
  layout: 'template',
  viewExt: 'html',
  cache: false,
  debug: true
});

app.use(async function (ctx) {
  await ctx.render('user');
});

app.listen(2104);
```

Or you can checkout the [example](https://github.com/koajs/ejs/tree/master/example).

### settings

* root: view root directory.
* layout: global layout file, default is `layout`, set `false` to disable layout.
* viewExt: view file extension (default `html`).
* cache: cache compiled templates (default `true`).
* debug: debug flag (default `false`).
* delimiter: character to use with angle brackets for open / close (default `%`).

### Layouts

`koa-ejs` supports layouts. The default layout file is `layout`. If you want to change default layout file, use `settings.layout`. Also you can specify layout by `options.layout` in `await ctx.render`.
Also you can set `layout = false` to disable the layout.

```
<html>
  <head>
    <title>koa ejs</title>
  </head>
  <body>
    <h3>koa ejs</h3>
    <%- body %>
  </body>
</html>
```

### Include

Supports ejs includes.

```
<div>
  <% include user.html %>
</div>
```

### State

Support [`ctx.state` in koa](https://github.com/koajs/koa/blob/master/docs/api/context.md#ctxstate).

## License

MIT license 

## Author

Developed & maintained by EMSA TECHNOLOGY COMPANY LTD (contact @ emsa-technology dot com).

---
_Source: https://npm.io/package/@blueprod/ws-view-koa-ejs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
