An open API service indexing awesome lists of open source software.

https://github.com/ramasilveyra/unreact

Convert React Components to EJS or Pug [Alpha][Unreleased]
https://github.com/ramasilveyra/unreact

ejs pug react

Last synced: about 1 month ago
JSON representation

Convert React Components to EJS or Pug [Alpha][Unreleased]

Awesome Lists containing this project

README

        



Last npm Registry Version


Build Status


Code coverage

Convert React Components to EJS or Pug (unreact)

The future is React without React.

EJS and Pug templates engines can be between 1647% and 7083% faster than ReactDOMServer.renderToString (React 15).

Table of Contents

- [Install](#install)
- [Usage](#usage)
- [Limitations](#limitations)
- [Future](#future)
- [Contribute](#contribute)
- [License](#license)

Install

**Node.js v8 or newer** is required.

Via the yarn client:

```bash
$ yarn add --dev unreact
```

Via the npm client:

```bash
$ npm install --save-dev unreact
```

Usage

### Convert Files (`--out-file`/`-o`)

```bash
unreact src/button.js --out-file views/button.pug
```

### Convert Directories (`--out-dir`/`-O`)

```bash
unreact src --out-dir views
```

### Template Engine (`--template-engine`/`-t`)

Default option is `pug`, you can also choose `ejs`.

```bash
unreact src/button.js --out-file views/button.ejs --template-engine ejs
unreact src --out-dir views -t ejs
```

### Add string to the beginning of the output file (`--add-beginning`)

```bash
unreact src/main.js --out-file views/main.pug --add-beginning "include header.pug"
```

### Add string to the ending of the output file (`--add-ending`)

```bash
unreact src/main.js --out-file views/main.pug --add-ending "include footer.pug"
```

### Change initial indent level (`--initial-indent-level`)

```bash
unreact src/main.js --out-file views/main.pug --initial-indent-level 1
```

Limitations

**ALPHA: things may not work**

- Only works with functional components and very simple ones.

Future

Check the work bridging React and Prepack:
- https://github.com/facebook/prepack/pulls?utf8=%E2%9C%93&q=is%3Apr+react
- https://twitter.com/trueadm/status/1002812303824314369
- https://github.com/trueadm/ssr-with-prepack-hackathon

Contribute

Feel free to dive in! [Open an issue](https://github.com/ramasilveyra/unreact/issues/new) or submit PRs.

unreact follows the [Contributor Covenant](https://contributor-covenant.org/version/1/4/) Code of Conduct.

License

[MIT](LICENSE.md)