-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
40 lines (36 loc) · 1.23 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Template Processor Test</title>
</head>
<body>
<h1>Template Processor Test</h1>
<h2>You should serve this file. It will CORS error if you just try to open the file.</h2>
<div id="output"></div>
<!--
serve this HTML file with http-server.
> npm install -g http-server
> http-server
Then point browser at http://127.0.0.1:8080/
-->
<script type="module">
import TemplateProcessor from "http://127.0.0.1:8080/dist/bundle.mjs"
// Wait for the document to load
document.addEventListener('DOMContentLoaded', async () => {
// Initialize the TemplateProcessor
const tp = new TemplateProcessor({
data: ["foo", "bar", "baz"],
view: [["div", {}, "/${ ($console.log($string($$.data));$join(data, ','))}"]]
}, {},{});
tp.logger.level = "debug"
await tp.initialize();
// Get the output element
const outputElement = document.getElementById('output');
// Display the processed data in the output element
outputElement.textContent = JSON.stringify(tp.output, null, 2);
});
</script>
</body>
</html>