Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/joe-sky/nornj-react
- Owner: joe-sky
- License: mit
- Created: 2016-12-04T04:19:51.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T22:53:28.000Z (about 2 years ago)
- Last Synced: 2024-10-27T21:34:28.314Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 880 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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