Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/joe-sky/nornj-react

React bindings for NornJ template engine.
https://github.com/joe-sky/nornj-react

Last synced: 21 days ago
JSON representation

React bindings for NornJ template engine.

Awesome Lists containing this project

README

        

# NornJ-React

React bindings for NornJ template engine.

[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][npm-url]
[![](https://img.shields.io/bundlephobia/minzip/[email protected]?style=flat)](https://bundlephobia.com/result?p=nornj-react@next)

### Install

```sh
npm install nornj-react
```

### bindTemplate

You can use `bindTemplate` to register React components to `NornJ` template engine.

* Class components

```js
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import nj from 'nornj';
import { bindTemplate } from 'nornj-react';

@bindTemplate
class TestComponent extends Component {
render() {
return {this.props.children};
}
}

ReactDOM.render(nj`test`(), document.body);
```

In addition, `bindTemplate` also support a `name` parameter:

```js
...
import { bindTemplate } from 'nornj-react';

@bindTemplate('test-Component')
class TestComponent extends Component {
render() {
return {this.props.children};
}
}

ReactDOM.render(nj`test`(), document.body);
```

* Function components

```js
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import nj from 'nornj';
import { bindTemplate } from 'nornj-react';

const TestComponent = bindTemplate('test-Component')(props => (
{props.children}
));

ReactDOM.render(nj`test`(), document.body);
```

### License

MIT

[npm-image]: http://img.shields.io/npm/v/nornj-react.svg
[downloads-image]: http://img.shields.io/npm/dm/nornj-react.svg
[npm-url]: https://www.npmjs.org/package/nornj-react