# ejs-browser-async

> Extension for EJS template engine to enable asynchronous template load.

Latest version **0.1.2** (published 2017-04-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install ejs-browser-async
pnpm add ejs-browser-async
yarn add ejs-browser-async
bun add ejs-browser-async
```

## 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.2 |
| Published | 2017-04-24 |
| First published | 2017-01-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | WON JONG YOO |
| Maintainers | devrama |
| Keywords | EJS, Extension, Template, Browser, Asynchronous, Include in Browser |

## Links

- npm: https://www.npmjs.com/package/ejs-browser-async
- Repository: https://github.com/Devrama/EJS-Browser-Async
- Homepage: https://github.com/Devrama/EJS-Browser-Async#readme
- Issues: https://github.com/Devrama/EJS-Browser-Async/issues
- npm.io page: https://npm.io/package/ejs-browser-async

## Dependencies (1)

- [ejs](https://npm.io/package/ejs.md) ^2.4.2

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.1.2 (latest) — 2017-04-24
- 0.1.1 — 2017-01-16
- 0.1.0 — 2017-01-16

## README

# EJS extension for asynchronous template load

* Load EJS template files asynchronously in browser.
* `include` support in browser, and it loads included templates recursively.

## Example
Example code is located in `/example` directory.

## How to use

### First, load EJS and this extension in your HTML page.
```html
  <script src="ejs-2.4.2.min.js" type="text/javascript"></script>
  <script src="ejs-browser-async.min.js" type="text/javascript"></script>
```

### API

### ejs.renderAsync(path, data, callback)
* **path**: relative to the page, or absolute path of the ejs template file
* **data**: parameters that you want to pass to the templates
* **callback**: callback function that gives you rendered string. callback has two arguments, `error` and `rendered`.
    * **error**: Error object if error occurs, otherwise null.
    * **rendered**: Rendered string result.

#### Example code of ejs.renderAsync
```javascript
  ejs.renderAsync(
    './templates/index.ejs',
    {
      sitename: 'EJS Async',
      copyright: 'Devrama.com'
    },
    function(err, rendered){
      if(!err){
        var el = document.getElementById('ejs-render');
        el.innerHTML = rendered;
      }
      else {
        throw new Error('EJS template error!');
      }
    }
  );
```

# License
MIT

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