react-lorem-component
Advanced tools
Comparing version 0.3.4 to 0.4.0
25
index.js
@@ -12,20 +12,19 @@ "use strict"; | ||
getDefaultProps: function() { | ||
return { count: 5, random: random, seed: 0 }; | ||
return { count: 5, seed: 0 }; | ||
}, | ||
getInitialState: function() { | ||
render: function() { | ||
var options = merge(this.props, { | ||
units: "paragraphs", | ||
format: "html", | ||
random: random | ||
}); | ||
random.seed(this.props.seed); | ||
var options = merge(this.props, { units: "paragraphs", format: "plain" }); | ||
var paragraphs = loremIpsum(options).split(/\r?\n/).filter(function(p) { return p.length; }); | ||
var html = loremIpsum(options); | ||
return { paragraphs: paragraphs }; | ||
}, | ||
render: function() { | ||
var content = this.state.paragraphs.map(function(paragraph, i) { | ||
return React.DOM.p({ key: i }, paragraph); | ||
}); | ||
return this.transferPropsTo(React.DOM.div(null, content)); | ||
return this.transferPropsTo( | ||
React.DOM.div({ dangerouslySetInnerHTML: { __html: html } }) | ||
); | ||
} | ||
@@ -32,0 +31,0 @@ }); |
{ | ||
"name": "react-lorem-component", | ||
"version": "0.3.4", | ||
"version": "0.4.0", | ||
"description": "A component for React that renders paragraph tags full of lorem ipsum text", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
11
spec.js
@@ -7,8 +7,15 @@ var assert = require("assert"); | ||
it("renders lorem ipsum text", function() { | ||
var component = LoremIpsum({ count: 1, words: ["foo"] }); | ||
var component = LoremIpsum({ | ||
count: 2, | ||
words: ["foo"], | ||
sentenceLowerBound: 3, | ||
sentenceUpperBound: 3, | ||
paragraphLowerBound: 2, | ||
paragraphUpperBound: 2 | ||
}); | ||
React.renderComponentToString(component, function(markup) { | ||
assert(/foo/.test(markup)); | ||
assert(/<p>Foo foo foo. Foo foo foo.<\/p><p>Foo foo foo. Foo foo foo.<\/p>/.test(markup)); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42
4800