Skip to content
This repository was archived by the owner on Dec 10, 2019. It is now read-only.

Commit b777658

Browse files
committed
namespace the pattern json and root container so we don't have name
collisions on view all pages
1 parent a9252d5 commit b777658

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

lib/engine_react.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ var engine_react = {
7070
const Component = React.createFactory(eval(nodeComponent.code));
7171

7272
return outputTemplate.render({
73+
patternPartial: pattern.patternPartial,
7374
json: JSON.stringify(data),
7475
htmlOutput: ReactDOMServer.renderToStaticMarkup(Component(data)),
7576
runtimeCode: runtimeComponent.code
@@ -131,10 +132,10 @@ var engine_react = {
131132
return unformattedString;
132133
},
133134

134-
markupOnlyCodeFormatter(unformattedString) {
135+
markupOnlyCodeFormatter(unformattedString, pattern) {
135136
const $ = cheerio.load(unformattedString);
136137
console.log('markupOnlyCodeFormatter()');
137-
return beautify.html($('#reactContainer').html(), {indent_size: 2});
138+
return beautify.html($('.reactPatternContainer').html(), {indent_size: 2});
138139
}
139140
};
140141

lib/outputTemplate.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
<div id="reactContainer">
1+
<div class="reactPatternContainer" id="reactPatternContainer--{{{patternPartial}}}">
22
{{{htmlOutput}}}
33
</div>
44

55
<!-- pattern JSON (React props) -->
6-
<script id="patternJSON" type="application/json">
6+
<script data-type="patternJSON" id="patternJSON--{{{patternPartial}}}" type="application/json">
77
{{{json}}}
88
</script>
99

@@ -13,6 +13,6 @@
1313
1414
<!-- runtime rendering -->
1515
var component = unknown.default;
16-
var patternJSON = document.getElementById('patternJSON').textContent;
17-
ReactDOM.render(React.createElement(component, JSON.parse(patternJSON)), document.getElementById('reactContainer'));
16+
var patternJSON = document.getElementById('patternJSON--{{{patternPartial}}}').textContent;
17+
ReactDOM.render(React.createElement(component, JSON.parse(patternJSON)), document.getElementById('reactPatternContainer--{{{patternPartial}}}'));
1818
</script>

0 commit comments

Comments
 (0)