Skip to content

Commit 8fc4f78

Browse files
authored
Merge pull request #4927 from FlowFuse/escape-flow
fix: escape Node-RED flow data to prevent htmlmin parse error
2 parents f0b442d + 88242de commit 8fc4f78

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

src/_includes/layouts/integration.njk

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,21 +265,22 @@ layout: layouts/base.njk
265265
</div>
266266

267267
{% if hasExamples %}
268+
{% for example in integration.examples %}
269+
{% if example.flow %}
270+
<script type="application/json" id="flow-data-{{ loop.index0 }}">{{ example.flow | safe }}</script>
271+
{% endif %}
272+
{% endfor %}
273+
268274
<!-- Flow Renderer Script -->
269275
<script type="module">
270276
import FlowRenderer from '/js/flowrenderer.min.js';
271277
272278
// Store flow data
273-
const flowData = [
274-
{% for example in integration.examples %}
275-
{% if example.flow %}
276-
{
277-
index: {{ loop.index0 }},
278-
flow: {{ example.flow | safe }}
279-
}{% if not loop.last %},{% endif %}
280-
{% endif %}
281-
{% endfor %}
282-
];
279+
const flowData = [];
280+
document.querySelectorAll('script[id^="flow-data-"]').forEach(el => {
281+
const index = parseInt(el.id.replace('flow-data-', ''), 10);
282+
flowData.push({ index, flow: JSON.parse(el.textContent) });
283+
});
283284
284285
// Add event listeners to tab buttons
285286
document.querySelectorAll('.tab-button').forEach(button => {

0 commit comments

Comments
 (0)