Skip to content
This repository has been archived by the owner on Jan 22, 2020. It is now read-only.

Commit

Permalink
Merge pull request #18 from paypal/develop
Browse files Browse the repository at this point in the history
PR #16 - merge develop into master
  • Loading branch information
samsel committed Apr 25, 2015
2 parents 19a54c9 + 536b614 commit 28530e1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.2.0 (April 25, 2015)

* Generate semantic html by injecting script tag before end of html tag
* https://github.com/paypal/react-engine/pull/16

## 1.1.0 (April 11, 2015)

* Added an API to the client side code to expose data.
Expand Down
5 changes: 3 additions & 2 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ exports.create = function create(createOptions) {
// render the componentInstance
html += React.renderToString(componentInstance);

// state injection
html += format(TEMPLATE, Config.client.markupId, JSON.stringify(data));
// state (script) injection
var script = format(TEMPLATE, Config.client.markupId, JSON.stringify(data));
html = html.replace('</body>', script + '</body>');

return done(null, html);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-engine",
"version": "1.1.0",
"version": "1.2.0",
"description": "a composite render engine for express apps to render both plain react views and react-router views",
"main": "index.js",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/assertions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"PROFILE_OUTPUT": "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Hello, world!</title></head><body><div id=\"profile\"><h1>Joshua</h1></div></body></html><script id=\"react-engine-props\" type=\"application/javascript\">var __REACT_ENGINE__ = {\"__meta\":{\"view\":\"profile.js\",\"markupId\":\"react-engine-props\"},\"title\":\"Hello, world!\",\"name\":\"Joshua\",\"cache\":false};</script>",
"PROFILE_OUTPUT_WITH_REACT_ATTRS": "<!DOCTYPE html><html data-reactid=\".hsq0etoagw\" data-react-checksum=\"-1803325012\"><head data-reactid=\".hsq0etoagw.0\"><meta charset=\"utf-8\" data-reactid=\".hsq0etoagw.0.0\"><title data-reactid=\".hsq0etoagw.0.1\">Hello, world!</title></head><body data-reactid=\".hsq0etoagw.1\"><div id=\"profile\" data-reactid=\".hsq0etoagw.1.0\"><h1 data-reactid=\".hsq0etoagw.1.0.0\">Joshua</h1></div></body></html><script id=\"react-engine-props\" type=\"application/javascript\">var __REACT_ENGINE__ = {\"__meta\":{\"view\":\"profile.js\",\"markupId\":\"react-engine-props\"},\"title\":\"Hello, world!\",\"name\":\"Joshua\",\"cache\":false};</script>",
"ACCOUNT_OUTPUT": "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Hello, world!</title></head><body><div id=\"account\"><h1>Joshua</h1></div></body></html><script id=\"react-engine-props\" type=\"application/javascript\">var __REACT_ENGINE__ = {\"__meta\":{\"view\":null,\"markupId\":\"react-engine-props\"},\"title\":\"Hello, world!\",\"name\":\"Joshua\",\"cache\":false};</script>"
"PROFILE_OUTPUT": "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Hello, world!</title></head><body><div id=\"profile\"><h1>Joshua</h1></div><script id=\"react-engine-props\" type=\"application/javascript\">var __REACT_ENGINE__ = {\"__meta\":{\"view\":\"profile.js\",\"markupId\":\"react-engine-props\"},\"title\":\"Hello, world!\",\"name\":\"Joshua\",\"cache\":false};</script></body></html>",
"PROFILE_OUTPUT_WITH_REACT_ATTRS": "<!DOCTYPE html><html data-reactid=\".hsq0etoagw\" data-react-checksum=\"-1803325012\"><head data-reactid=\".hsq0etoagw.0\"><meta charset=\"utf-8\" data-reactid=\".hsq0etoagw.0.0\"><title data-reactid=\".hsq0etoagw.0.1\">Hello, world!</title></head><body data-reactid=\".hsq0etoagw.1\"><div id=\"profile\" data-reactid=\".hsq0etoagw.1.0\"><h1 data-reactid=\".hsq0etoagw.1.0.0\">Joshua</h1></div><script id=\"react-engine-props\" type=\"application/javascript\">var __REACT_ENGINE__ = {\"__meta\":{\"view\":\"profile.js\",\"markupId\":\"react-engine-props\"},\"title\":\"Hello, world!\",\"name\":\"Joshua\",\"cache\":false};</script></body></html>",
"ACCOUNT_OUTPUT": "<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>Hello, world!</title></head><body><div id=\"account\"><h1>Joshua</h1></div><script id=\"react-engine-props\" type=\"application/javascript\">var __REACT_ENGINE__ = {\"__meta\":{\"view\":null,\"markupId\":\"react-engine-props\"},\"title\":\"Hello, world!\",\"name\":\"Joshua\",\"cache\":false};</script></body></html>"
}

0 comments on commit 28530e1

Please sign in to comment.