Added a Go template playground
All checks were successful
/ publish (push) Successful in 55s

This commit is contained in:
Leon Mika 2025-09-26 17:28:30 +10:00
parent e4ab1358e9
commit d1dee7bc3d
8 changed files with 148 additions and 2 deletions

View file

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Go Template Playground - Tools</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css">
<link rel="stylesheet" href="style.css">
</head>
<body class="container">
<header>
<hgroup>
<h1>Go Template Playground</h1>
<p>Playground of <a href="https://pkg.go.dev/text/template" target="_blank">text/template</a>.</p>
</hgroup>
</header>
<div class="inputs grid">
<div class="text-display">
<textarea id="template" placeholder="Template code">Hello, {{.what}}</textarea>
<div id="template-message"></div>
</div>
<div class="text-display">
<textarea id="data" placeholder="JSON data">{"what":"world"}</textarea>
<div id="data-message"></div>
</div>
</div>
<div class="output">
<div id="output"></div>
</div>
<script src="main.js" type="module"></script>
</body>
</html>

8
site/gotemplate/main.js Normal file
View file

@ -0,0 +1,8 @@
import "/wasm/wasm_exec.js";
const go = new Go();
WebAssembly.instantiateStreaming(fetch("/wasm/gotemplate.wasm"), go.importObject)
.then((result) => {
go.run(result.instance);
});

View file

@ -0,0 +1,3 @@
textarea {
height: 15rem;
}