Skip to content

Commit cfffc97

Browse files
Merge pull request #26 from remarkablemark/examples
Add examples
2 parents 43f46ce + e48a9f0 commit cfffc97

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
test
22
coverage
3+
examples
34
webpack.config.js
45
.eslint*
56
.travis*

examples/requirejs.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Load with Require.js (AMD)</title>
6+
</head>
7+
<body style="padding: 50px">
8+
<div id="root"></div>
9+
10+
<!-- Require.js -->
11+
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.2/require.min.js"></script>
12+
13+
<script>
14+
requirejs.config({
15+
paths: {
16+
'html-react-parser': 'https://unpkg.com/html-react-parser@latest/dist/html-react-parser.min',
17+
'react': 'https://unpkg.com/react@latest/dist/react.min',
18+
'react-dom': 'https://unpkg.com/react-dom@latest/dist/react-dom.min'
19+
}
20+
});
21+
22+
requirejs([
23+
'react-dom', 'html-react-parser'
24+
], function(ReactDOM, HTMLReactParser) {
25+
ReactDOM.render(
26+
HTMLReactParser(
27+
'<h2 style="font-family:\'Lucida Grande\';">' +
28+
'HTMLReactParser loaded with Require.js' +
29+
'<\/h2>'
30+
),
31+
document.getElementById('root')
32+
);
33+
});
34+
</script>
35+
</body>
36+
</html>

examples/script-tag.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Load with Script Tag</title>
6+
</head>
7+
<body style="padding: 50px">
8+
<div id="root"></div>
9+
10+
<!-- HTMLReactParser depends on React -->
11+
<script src="https://unpkg.com/react@latest/dist/react.min.js"></script>
12+
<script src="https://unpkg.com/html-react-parser@latest/dist/html-react-parser.min.js"></script>
13+
14+
<!-- ReactDOM -->
15+
<script src="https://unpkg.com/react-dom@latest/dist/react-dom.min.js"></script>
16+
<script>
17+
ReactDOM.render(
18+
HTMLReactParser(
19+
'<h2 style="font-family:\'Lucida Grande\';">' +
20+
'HTMLReactParser loaded with script tag' +
21+
'<\/h2>'
22+
),
23+
document.getElementById('root')
24+
);
25+
</script>
26+
</body>
27+
</html>

0 commit comments

Comments
 (0)