Skip to content

Instantly share code, notes, and snippets.

@zpao
Created March 30, 2014 02:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zpao/9866377 to your computer and use it in GitHub Desktop.
Save zpao/9866377 to your computer and use it in GitHub Desktop.
express-react-views. All server generated, no client mount or anything.
// normal express stuff
app.set('view engine', 'jsx');
app.engine('jsx', require('express-react-views').__express);
// the rest of it
exports.index = function(req, res){
res.render('index', { title: 'Express' });
};
/**
* @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;
/**
* @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