From 7bbc58e3cc5504844fba144a71cd8c634c0400c4 Mon Sep 17 00:00:00 2001 From: Jan Andrle Date: Mon, 9 Oct 2023 13:51:55 +0200 Subject: [PATCH] `elCode` --- docs_src/components/example.html.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/docs_src/components/example.html.js b/docs_src/components/example.html.js index f8b06da..8a10c67 100644 --- a/docs_src/components/example.html.js +++ b/docs_src/components/example.html.js @@ -24,17 +24,16 @@ export function example({ src, language= "javascript" }){ }) ) ), - el("script", ` - Flems(document.getElementById("${id}"), { - files: [{ - name: ".js", - content: ${JSON.stringify(code)} - }], - toolbar: false, - }) - `) + elCode({ id, content: code }) ); } +function elCode({ id, content }){ + const options= JSON.stringify({ + files: [{ name: ".js", content }], + toolbar: false + }); + return el("script", `Flems(document.getElementById("${id}"), JSON.parse(${options}));`); +} function register(){ if(loaded) return; document.head.append(