Created
March 30, 2014 02:19
-
-
Save zpao/9866377 to your computer and use it in GitHub Desktop.
express-react-views. All server generated, no client mount or anything.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// normal express stuff | |
app.set('view engine', 'jsx'); | |
app.engine('jsx', require('express-react-views').__express); | |
// the rest of it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.index = function(req, res){ | |
res.render('index', { title: 'Express' }); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @jsx React.DOM | |
*/ | |
var React = require('react'); | |
var Layout = require('./layout'); | |
var Index = React.createClass({ | |
render: function() { | |
return ( | |
<Layout title={this.props.title}> | |
<h1>{this.props.title}</h1> | |
<p>Welcome to {this.props.title}</p> | |
</Layout> | |
); | |
} | |
}); | |
module.exports = Index; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @jsx React.DOM | |
*/ | |
var React = require('react'); | |
var Layout = React.createClass({ | |
render: function() { | |
return ( | |
<html> | |
<head> | |
<title>{this.props.title}</title> | |
<link rel="stylesheet" href="/stylesheets/style.css" /> | |
</head> | |
<body> | |
{this.props.children} | |
</body> | |
</html> | |
); | |
} | |
}); | |
module.exports = Layout; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment