Build doc
This commit is contained in:
parent
3481d174f2
commit
18c2d12ecb
2 changed files with 80 additions and 78 deletions
|
|
@ -22,7 +22,7 @@ Checkbox func NewFieldCheckbox(name string) *Field field := form.NewFieldCheckbo
|
|||
<meta itemprop="name" content="Fields">
|
||||
<meta itemprop="description" content="A field represents a field in a form.
|
||||
Checkbox func NewFieldCheckbox(name string) *Field field := form.NewFieldCheckbox("Foo") Test me Run Try it yourself ↗ Share ↗ Generates an input[type=checkbox]">
|
||||
<meta itemprop="wordCount" content="668">
|
||||
<meta itemprop="wordCount" content="666">
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:title" content="Fields">
|
||||
<meta name="twitter:description" content="A field represents a field in a form.
|
||||
|
|
@ -788,24 +788,19 @@ func r(f *form.Form) {
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<details class="last-of-type:hx-mb-0 hx-rounded-lg hx-bg-neutral-50 dark:hx-bg-neutral-800 hx-p-2 hx-mt-4 hx-group" >
|
||||
<summary class="hx-flex hx-items-center hx-cursor-pointer hx-select-none hx-list-none hx-p-1 hx-rounded hx-transition-colors hover:hx-bg-gray-100 dark:hover:hx-bg-neutral-800 before:hx-mr-1 before:hx-inline-block before:hx-transition-transform before:hx-content-[''] dark:before:hx-invert rtl:before:hx-rotate-180 group-open:before:hx-rotate-90">
|
||||
<strong class="hx-text-lg">Test me</strong>
|
||||
</summary>
|
||||
<div class="hx-p-2 hx-overflow-hidden">
|
||||
<pre class="hidden">
|
||||
<pre class="hidden">
|
||||
field := form.NewFieldCsrf("Foo")
|
||||
</pre>
|
||||
<details>
|
||||
<summary class="hugo-goplay-summary">Test me</summary>
|
||||
<textarea class="hugo-goplay-textarea" id="pre-5a79ddcdf1338aaf0694e435ee687dcb"></textarea>
|
||||
<div id="5a79ddcdf1338aaf0694e435ee687dcb" class="hugo-goplay-result"></div>
|
||||
<textarea class="hugo-goplay-textarea" id="pre-2244850816348a135e01f7a2614d6b7a"></textarea>
|
||||
<div id="2244850816348a135e01f7a2614d6b7a" class="hugo-goplay-result"></div>
|
||||
<div class="hugo-goplay-toolbox">
|
||||
<button role="button" class="hugo-goplay-button" onclick=goplayRenderCompile_5a79ddcdf1338aaf0694e435ee687dcb()>Run</button>
|
||||
<button role="button" class="hugo-goplay-button" onclick=goplayOpenShare_5a79ddcdf1338aaf0694e435ee687dcb()>
|
||||
<button role="button" class="hugo-goplay-button" onclick=goplayRenderCompile_2244850816348a135e01f7a2614d6b7a()>Run</button>
|
||||
<button role="button" class="hugo-goplay-button" onclick=goplayOpenShare_2244850816348a135e01f7a2614d6b7a()>
|
||||
Try it yourself ↗
|
||||
</button>
|
||||
<button role="button" class="hugo-goplay-button" onclick=goplayOpenShare_5a79ddcdf1338aaf0694e435ee687dcb()>Share ↗</button>
|
||||
<button role="button" class="hugo-goplay-button" onclick=goplayOpenShare_2244850816348a135e01f7a2614d6b7a()>Share ↗</button>
|
||||
</div>
|
||||
</details>
|
||||
<style>
|
||||
|
|
@ -826,7 +821,7 @@ Try it yourself ↗
|
|||
.hugo-goplay-result pre {
|
||||
padding: 1rem;
|
||||
}
|
||||
#5a79ddcdf1338aaf0694e435ee687dcb code {
|
||||
#2244850816348a135e01f7a2614d6b7a code {
|
||||
background: none !important;
|
||||
border: 0 !important;
|
||||
}
|
||||
|
|
@ -863,71 +858,78 @@ Try it yourself ↗
|
|||
<script type="module">
|
||||
import { GoPlayProxy } from "https://unpkg.com/@ggicci/goplay/dist/index.js";
|
||||
const goplay = new GoPlayProxy("https://gp.deblan.gitnet.page");
|
||||
<p>function normalizeCode(code) {
|
||||
code = code
|
||||
.trim()
|
||||
.replace(/^<code>go/, "") .replace(/^</code>/, “”)
|
||||
.replace(/```$/, “”)
|
||||
.replace(/<([^>]+)>/g, “”)
|
||||
.trim();</p>
|
||||
<pre><code> let lines = code.split("\n");
|
||||
|
||||
for (let i in lines) {
|
||||
lines[i] = [" ", lines[i]].join("")
|
||||
function normalizeCode(code) {
|
||||
code = code
|
||||
.trim()
|
||||
.replace(/^```go/, "")
|
||||
.replace(/^```/, "")
|
||||
.replace(/```$/, "")
|
||||
.replace(/<([^>]+)>/g, "")
|
||||
.trim();
|
||||
|
||||
let lines = code.split("\n");
|
||||
|
||||
for (let i in lines) {
|
||||
lines[i] = [" ", lines[i]].join("")
|
||||
}
|
||||
|
||||
code = lines.join("\n");
|
||||
code = `package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"strings"
|
||||
|
||||
"gitnet.fr/deblan/go-form/form"
|
||||
"gitnet.fr/deblan/go-form/theme"
|
||||
)
|
||||
|
||||
func main() {
|
||||
${code}
|
||||
|
||||
r(form.NewForm(field))
|
||||
}
|
||||
|
||||
func r(f *form.Form) {
|
||||
render := theme.NewRenderer(theme.Html5)
|
||||
tpl, _ := template.New("example").Funcs(render.FuncMap()).Parse(\`\{\{ form_widget (.Form.GetField \"Foo\") \}\}\`)
|
||||
b := new(strings.Builder)
|
||||
tpl.Execute(b, map[string]any{"Form": f})
|
||||
fmt.Println(b.String())
|
||||
}
|
||||
`;
|
||||
|
||||
return code
|
||||
}
|
||||
|
||||
code = lines.join("\n");
|
||||
code = `package main
|
||||
</code></pre>
|
||||
<p>import (
|
||||
“fmt”
|
||||
“html/template”
|
||||
“strings”</p>
|
||||
<pre><code>"gitnet.fr/deblan/go-form/form"
|
||||
"gitnet.fr/deblan/go-form/theme"
|
||||
</code></pre>
|
||||
<p>)</p>
|
||||
<p>func main() {
|
||||
${code}</p>
|
||||
<pre><code>r(form.NewForm(field))
|
||||
</code></pre>
|
||||
<p>}</p>
|
||||
<p>func r(f *form.Form) {
|
||||
render := theme.NewRenderer(theme.Html5)
|
||||
tpl, _ := template.New(“example”).Funcs(render.FuncMap()).Parse(`{{ form_widget (.Form.GetField "Foo") }}`)
|
||||
b := new(strings.Builder)
|
||||
tpl.Execute(b, map[string]any{“Form”: f})
|
||||
fmt.Println(b.String())
|
||||
}
|
||||
`;</p>
|
||||
<pre><code>return code
|
||||
</code></pre>
|
||||
<p>}</p>
|
||||
<p>const normalizedCode = normalizeCode("\u003cpre class=\u0022hidden\u0022\u003e\nfield := form.NewFieldCsrf(\u0022Foo\u0022)\n\u003c/pre\u003e\n")
|
||||
const textarea = document.getElementById(“pre-5a79ddcdf1338aaf0694e435ee687dcb”)
|
||||
textarea.value = normalizedCode
|
||||
textarea.style.height = textarea.scrollHeight + “px”;
|
||||
textarea.style.overflowY = “hidden”;</p>
|
||||
<p>textarea.addEventListener(“input”, function() {
|
||||
this.style.height = “auto”;
|
||||
this.style.height = this.scrollHeight + “px”;
|
||||
});</p>
|
||||
<p>window[“goplayRenderCompile_” + “5a79ddcdf1338aaf0694e435ee687dcb”] = () => {
|
||||
const parent = document.getElementById(“5a79ddcdf1338aaf0694e435ee687dcb”)
|
||||
const pre = document.createElement(‘pre’)
|
||||
const container = document.createElement(‘code’)
|
||||
container.classList.add(’text’)
|
||||
pre.appendChild(container)
|
||||
parent.replaceChildren(pre)
|
||||
goplay.renderCompile(container, textarea.value);
|
||||
};</p>
|
||||
<p>window[“goplayOpenShare_” + “5a79ddcdf1338aaf0694e435ee687dcb”] = async() => {
|
||||
const shareUrl = await goplay.share(normalizedCode)
|
||||
window.open(shareUrl, “_blank”).focus();
|
||||
};
|
||||
</script></p>
|
||||
</div>
|
||||
</details>
|
||||
const normalizedCode = normalizeCode("\n\u003cpre class=\u0022hidden\u0022\u003e\nfield := form.NewFieldCsrf(\u0022Foo\u0022)\n\u003c\/pre\u003e\n")
|
||||
const textarea = document.getElementById("pre-2244850816348a135e01f7a2614d6b7a")
|
||||
textarea.value = normalizedCode
|
||||
textarea.style.height = textarea.scrollHeight + "px";
|
||||
textarea.style.overflowY = "hidden";
|
||||
|
||||
textarea.addEventListener("input", function() {
|
||||
this.style.height = "auto";
|
||||
this.style.height = this.scrollHeight + "px";
|
||||
});
|
||||
|
||||
window["goplayRenderCompile_" + "2244850816348a135e01f7a2614d6b7a"] = () => {
|
||||
const parent = document.getElementById("2244850816348a135e01f7a2614d6b7a")
|
||||
const pre = document.createElement('pre')
|
||||
const container = document.createElement('code')
|
||||
container.classList.add('text')
|
||||
pre.appendChild(container)
|
||||
parent.replaceChildren(pre)
|
||||
goplay.renderCompile(container, textarea.value);
|
||||
};
|
||||
|
||||
window["goplayOpenShare_" + "2244850816348a135e01f7a2614d6b7a"] = async() => {
|
||||
const shareUrl = await goplay.share(normalizedCode)
|
||||
window.open(shareUrl, "_blank").focus();
|
||||
};
|
||||
</script>
|
||||
<h3>Date<span class="hx-absolute -hx-mt-20" id="date"></span>
|
||||
<a href="#date" class="subheading-anchor" aria-label="Permalink for this section"></a></h3><div class="hextra-code-block hx-relative hx-mt-6 first:hx-mt-0 hx-group/code">
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue