# complate-stream

> complate's core library for server-side rendering via JSX

Latest version **0.16.10** (published 2021-12-08) · Apache-2.0 license · 0 weekly downloads

## Install

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

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.16.10 |
| Published | 2021-12-08 |
| First published | 2017-05-31 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 32.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | FND |
| Maintainers | fnd |

## Links

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

## Recent versions

- 0.16.10 (latest) — 2021-12-08
- 0.16.9 — 2019-10-11
- 0.16.8 — 2019-10-11
- 0.16.7 — 2019-03-26
- 0.16.6 — 2019-03-20
- 0.16.5 — 2018-11-06
- 0.16.4 — 2018-06-30
- 0.16.3 — 2018-02-25
- 0.16.2 — 2018-02-21
- 0.16.1 — 2018-02-20
- 0.16.0 — 2018-02-05
- 0.15.0 — 2018-02-02
- 0.14.2 — 2017-11-16
- 0.14.1 — 2017-11-16
- 0.14.0 — 2017-11-03
- … 19 more at https://npm.io/package/complate-stream/versions

## README

complate-stream
===============

[complate](https://complate.org)'s core library for rendering HTML

[![package version](https://img.shields.io/npm/v/complate-stream.svg?style=flat)](https://www.npmjs.com/package/complate-stream)
[![build status](https://travis-ci.org/complate/complate-stream.svg?branch=master)](https://travis-ci.org/complate/complate-stream)
[![Greenkeeper badge](https://badges.greenkeeper.io/complate/complate-stream.svg)](https://greenkeeper.io)


How It Works
------------

At the core of complate-stream lies `generateHTML`, an implementation of the
signature expected by [JSX](https://facebook.github.io/jsx/) (as
[pioneered by React](https://reactjs.org/docs/jsx-in-depth.html)). When invoked,
that function returns an "element generator"; a function serving as placeholder
for the HTML element to be generated:

```javascript
generateHTML("html", { lang: "en" },
        generateHTML("body", { id: "top" },
                generateHTML("h1", null, "hello world"),
                generateHTML("p", null, "lorem ipsum")));
```

This indirection is necessary primarily to ensure proper order and nesting, as
function arguments are evaluated before the surrounding invocation – otherwise
the code above would emit `<h1>` and `<p>` before the `<body>` and `<html>`
elements.

Thus the example above returns a hierarchy of element generators, encapsulated
by a single element generator at the root, which upon invocation writes HTML to
the `stream` object being passed in:

```javascript
let element = generateHTML(…);
element(stream, …);
```

(`stream` is expected to support the methods `#write`, `#writeln` and `#flush`;
see `BufferedStream` for a sample implementation).

With our example, this should result in the following string being emitted:

```html
<html lang="en"><body id="top"><h1>hello world</h1><p>lorem ipsum</p></body></html>
```

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