Debian Codegraph @

packages/babel-standalone/examples/scriptTag-custom.htm

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8" />
5 <title>babel-standalone example - Script tag</title>
6 </head>
7 <body>
8 Using Babel <strong id="version"></strong>:
9 <pre id="output">Loading...</pre>
10
11 <script src="../babel.js"></script>
12 <script type="text/javascript">
13 // just disable the auto transformation
14 Babel.disableScriptTags();
15
16 var script = document.createElement('script');
17 script.type = 'text/babel';
18 script.text = "const doStuff = () => {" +
19 " const name = 'world';" +
20 " document.getElementById('output').innerHTML = `Hello ${name}`;" +
21 " document.getElementById('version').innerHTML = Babel.version;" +
22 "};" +
23 "doStuff();";
24 document.querySelector('head').appendChild(script)
25
26 // transform when you want to
27 Babel.transformScriptTags()
28 </script>
29 </body>
30 </html>