Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Added the ability to produce non-static markup #25

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@ option | values | default
`jsx.extension` | any file extension with leading `.` | `".jsx"`
`doctype` | any string that can be used as [a doctype](http://en.wikipedia.org/wiki/Document_type_declaration), this will be prepended to your document | `"<!DOCTYPE html>"`
`beautify` | `true`: beautify markup before outputting (note, this can affect rendering due to additional whitespace) | `false`
`static` | `true`: render markup which does not include the `data-react-checksum` or `data-reactid` fields | `true`

The defaults are sane, but just in case you want to change something, here's how it would look:

12 changes: 9 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -19,7 +19,8 @@ var DEFAULT_OPTIONS = {
stripTypes: false
},
doctype: '<!DOCTYPE html>',
beautify: false
beautify: false,
static: true
};

function createEngine(engineOptions) {
@@ -44,8 +45,13 @@ function createEngine(engineOptions) {
var component = require(filename);
// Transpiled ES6 may export components as { default: Component }
component = component.default || component;
markup +=
React.renderToStaticMarkup(React.createElement(component, options));
if (engineOptions.static) {
markup +=
React.renderToStaticMarkup(React.createElement(component, options));
} else {
markup +=
React.renderToString(React.createElement(component, options));
}
} catch (e) {
return cb(e);
}