├── .gitignore ├── .jshintrc ├── README.md ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | node_modules/ 3 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "asi": false, 3 | "bitwise": true, 4 | "browser": false, 5 | "curly": false, 6 | "eqeqeq": true, 7 | "eqnull": true, 8 | "esnext": false, 9 | "immed": true, 10 | "latedef": false, 11 | "newcap": false, 12 | "noarg": true, 13 | "nonew": true, 14 | "quotmark": false, 15 | "undef": true, 16 | "unused": "vars", 17 | "globalstrict": true, 18 | "trailing": false, 19 | "validthis": true, 20 | "loopfunc": true, 21 | "expr": true, 22 | "globals": { 23 | "Buffer": true, 24 | "define": true, 25 | "module": true, 26 | "require": true, 27 | "exports": true, 28 | "describe": true, 29 | "xdescribe": true, 30 | "beforeEach": true, 31 | "afterEach": true, 32 | "it": true, 33 | "xit": true, 34 | "escape": true, 35 | "process": true, 36 | "__dirname": true 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # express-react-engine 2 | 3 | This is an [Express](http://expressjs.com) view engine for [React's](http://http://facebook.github.io/react/) JSX that supports server side rendering and **it is not limited to static markdown**. 4 | 5 | ## Usage 6 | 7 | ``` 8 | npm install express-react-engine react react-dom 9 | ``` 10 | 11 | Make sure you install `react` and `react-dom` as dependencies. 12 | 13 | 14 | ### Add it to your Express App 15 | 16 | ```javascript 17 | var ReactEngine = require('express-react-engine'); 18 | var app = express(); 19 | 20 | app.set('views', __dirname + '/components'); 21 | app.engine('jsx', ReactEngine()); 22 | ``` 23 | 24 | Change your *views directory* to match your *components directory* and set `jsx` as your view engine. 25 | 26 | 27 | ## Options 28 | 29 | `wrapper` is a React component that renders the Html element as well as the initial props and children Html. 30 | 31 | ### Example 32 | 33 | ``` javascript 34 | app.engine('jsx', reactEngine({wrapper: 'html.jsx'})); 35 | ``` 36 | 37 | **/components/html.jsx** 38 | ``` javascript 39 | var React = require('react'); 40 | 41 | var Html = React.createClass({ 42 | render: function () { 43 | return ( 44 | 45 | 46 | {this.props.props.title} 47 | 48 | 49 | 50 |
51 |