Build doc

This commit is contained in:
CI 2025-07-28 14:04:03 +00:00
commit 18c2d12ecb
2 changed files with 80 additions and 78 deletions

View file

@ -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(&#34;Foo&#34;) 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 &#8599;
</button>
<button role="button" class="hugo-goplay-button" onclick=goplayOpenShare_5a79ddcdf1338aaf0694e435ee687dcb()>Share &#8599;</button>
<button role="button" class="hugo-goplay-button" onclick=goplayOpenShare_2244850816348a135e01f7a2614d6b7a()>Share &#8599;</button>
</div>
</details>
<style>
@ -826,7 +821,7 @@ Try it yourself &#8599;
.hugo-goplay-result pre {
padding: 1rem;
}
#5a79ddcdf1338aaf0694e435ee687dcb code {
#2244850816348a135e01f7a2614d6b7a code {
background: none !important;
border: 0 !important;
}
@ -863,71 +858,78 @@ Try it yourself &#8599;
<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/, &quot;&quot;) .replace(/^</code>/, &ldquo;&rdquo;)
.replace(/```$/, &ldquo;&rdquo;)
.replace(/&lt;([^&gt;]+)&gt;/g, &ldquo;&rdquo;)
.trim();</p>
<pre><code> let lines = code.split(&quot;\n&quot;);
for (let i in lines) {
lines[i] = [&quot; &quot;, lines[i]].join(&quot;&quot;)
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(&quot;\n&quot;);
code = `package main
</code></pre>
<p>import (
&ldquo;fmt&rdquo;
&ldquo;html/template&rdquo;
&ldquo;strings&rdquo;</p>
<pre><code>&quot;gitnet.fr/deblan/go-form/form&quot;
&quot;gitnet.fr/deblan/go-form/theme&quot;
</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(&ldquo;example&rdquo;).Funcs(render.FuncMap()).Parse(`{{ form_widget (.Form.GetField &quot;Foo&quot;) }}`)
b := new(strings.Builder)
tpl.Execute(b, map[string]any{&ldquo;Form&rdquo;: f})
fmt.Println(b.String())
}
`;</p>
<pre><code>return code
</code></pre>
<p>}</p>
<p>const normalizedCode = normalizeCode(&quot;\u003cpre class=\u0022hidden\u0022\u003e\nfield := form.NewFieldCsrf(\u0022Foo\u0022)\n\u003c/pre\u003e\n&quot;)
const textarea = document.getElementById(&ldquo;pre-5a79ddcdf1338aaf0694e435ee687dcb&rdquo;)
textarea.value = normalizedCode
textarea.style.height = textarea.scrollHeight + &ldquo;px&rdquo;;
textarea.style.overflowY = &ldquo;hidden&rdquo;;</p>
<p>textarea.addEventListener(&ldquo;input&rdquo;, function() {
this.style.height = &ldquo;auto&rdquo;;
this.style.height = this.scrollHeight + &ldquo;px&rdquo;;
});</p>
<p>window[&ldquo;goplayRenderCompile_&rdquo; + &ldquo;5a79ddcdf1338aaf0694e435ee687dcb&rdquo;] = () =&gt; {
const parent = document.getElementById(&ldquo;5a79ddcdf1338aaf0694e435ee687dcb&rdquo;)
const pre = document.createElement(&lsquo;pre&rsquo;)
const container = document.createElement(&lsquo;code&rsquo;)
container.classList.add(&rsquo;text&rsquo;)
pre.appendChild(container)
parent.replaceChildren(pre)
goplay.renderCompile(container, textarea.value);
};</p>
<p>window[&ldquo;goplayOpenShare_&rdquo; + &ldquo;5a79ddcdf1338aaf0694e435ee687dcb&rdquo;] = async() =&gt; {
const shareUrl = await goplay.share(normalizedCode)
window.open(shareUrl, &ldquo;_blank&rdquo;).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