# complate-express

> complate integration for Express

Latest version **0.16.0** (published 2018-06-30) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install complate-express
pnpm add complate-express
yarn add complate-express
bun add complate-express
```

## 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.16.0 |
| Published | 2018-06-30 |
| First published | 2017-07-22 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | FND |
| Maintainers | fnd |

## Links

- npm: https://www.npmjs.com/package/complate-express
- Repository: https://github.com/complate/complate-express
- Issues: https://github.com/complate/complate-express/issues
- npm.io page: https://npm.io/package/complate-express

## Dependencies (1)

- [complate-stream](https://npm.io/package/complate-stream.md) 0.x

## Recent versions

- 0.16.0 (latest) — 2018-06-30
- 0.15.0 — 2017-11-11
- 0.14.0 — 2017-11-07
- 0.13.0 — 2017-11-03
- 0.12.1 — 2017-09-19
- 0.12.0 — 2017-09-19
- 0.11.0 — 2017-08-15
- 0.10.1 — 2017-08-09
- 0.10.0 — 2017-08-09
- 0.9.1 — 2017-08-03
- 0.9.0 — 2017-07-31
- 0.8.0 — 2017-07-22

## README

# complate-express

[Express](http://expressjs.com) adaptor for [complate](https://complate)


Getting Started
---------------

Install complate-express in your Express application:

```
$ npm install complate-express
```

Register complate's middleware, then use `Response#complate` for rendering:

```javascript
let express = require("express");
let complate = require("complate-express");

let app = express();
// register complate middleware
app.use(complate("/path/to/views.js")));

app.get("/", (req, res) => {
    res.complate("MyView", { title: "Hello World" });
});
```

Views are typically generated from JSX modules:

```jsx
import { createElement } from "complate-stream";

export function MyView({ title }) {
    return <article>
        <h1>{title}</h1>
        <p>lorem ipsum dolor sit amet</p>
    </article>;
}

// host API
export default (view, params, stream, fragment, callback) => {
    return renderer.renderView(view, params, stream, { fragment }, callback);
};
```

These JSX modules are then combined into a single `views.js` bundle, e.g. using
[faucet](https://faucet-pipeline.org) - see
[complate-sample-express](https://github.com/complate/complate-sample-express)
for details.


API
---

`Request#complate(viewName, params, options)`

* `viewName` identifies the view within the bundle
* `params` is an object passed to the respective view macro
* `options` is an optional object with the following members:
    * `fragment`, if `true`, indicates that an HTML fragment (omitting doctype
      and layout)
    * `statusCode` sets the HTTP status code (defaults to `200`)
    * `contentType` sets the corresponding HTTP response header (defaults to
      `"text/html"`)

If Express's view cache is disabled, the bundle will be reloaded for each
requests (useful for development).

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