gulp-html-to-react
A Gulp plugin to turn HTML into React component with embedded React code.
Based on reactjs/react-magic.
Table of Contents
Install
$ npm i -D gulp-html-to-react
Or:
$ npm install --save-dev gulp-html-to-react
Usage
'use strict'; var toreact = diff = ; module{ gulp; };
Used with stream or buffer. See gulp.src/options.buffer
Embedding React code in HTML
A special tag can be used to write React code embedded in an HTML document.
<?REACT...?>
Example:
<?REACTthis.props.value?>
Giving:
alert('click')}> {this.props.value}
Options
indent
Type: string
Default value: \t
Character(s) to be used for indenting the component.
encoding
Type: string
Default value: utf8
Type of the encoding for the output.
ext
Type: string
Default value: null
The extension for the output file. When null
, the extension remain the same as the input file.
style
Type: integer
Default value: 0
The style to be used to create the component.
Values:
0
: React.Component (~ v16.2.0)1
: React.createClass (~ v15.6.2)2
: var3
: createReactClass (create-react-class needed)