Build doc
This commit is contained in:
parent
6f6a534e1a
commit
17ecc007f6
2 changed files with 14 additions and 13 deletions
|
|
@ -12,7 +12,7 @@
|
|||
<link fetchpriority="low" href="/go-form/site.webmanifest" rel="manifest" />
|
||||
<title>Rendering – deblan/go-form</title>
|
||||
<meta name="description" content="go-form allows you to render a form using Go’s built-in template engine. Here is a simple example that displays a form:
|
||||
myForm := form.NewForm(...) render := theme.NewRenderer(theme.Bootstrap5) tpl, _ := template.New("page").Funcs(render.FuncMap()).Parse(` <html> <head> <title>My form</title> </head> <body> {{ form .Form }} </body> </html> `) b := new(strings.Builder) tpl.Execute(w, map[string]any{ "Form": myForm, }) fmt.Println(b.String()) @import "fmt" @import "html/template" @import "strings" @import @import "github.com/yosssi/gohtml" @import "gitnet.fr/deblan/go-form/example" @import "gitnet.fr/deblan/go-form/theme" form := example.CreateDataForm() render := theme.NewRenderer(theme.Bootstrap5) tpl, _ := template.New("page").Funcs(render.FuncMap()).Parse(`{{ form .Form }}`) buff := new(strings.Builder) tpl.Execute(buff, map[string]any{ "Form": form, }) fmt.Println(gohtml.Format(buff.String())) Test me Run Try it yourself ↗ Share ↗ Other helper functions are available to render specific parts of the form:" /><link rel="canonical" href="https://deblan.gitnet.page/go-form/docs/rendering/" itemprop="url" />
|
||||
myForm := form.NewForm(...) render := theme.NewRenderer(theme.Bootstrap5) tpl, _ := template.New("page").Funcs(render.FuncMap()).Parse(` <html> <head> <title>My form</title> </head> <body> {{ form .Form }} </body> </html> `) b := new(strings.Builder) tpl.Execute(w, map[string]any{ "Form": myForm, }) fmt.Println(b.String()) @import "fmt" @import "html/template" @import "strings" @import @import "github.com/yosssi/gohtml" @import "gitnet.fr/deblan/go-form/example" @import "gitnet.fr/deblan/go-form/theme" form := example.CreateDataForm() render := theme.NewRenderer(theme.Html5) // render := theme.NewRenderer(theme.Bootstrap5) tpl, _ := template.New("page").Funcs(render.FuncMap()).Parse(`{{ form .Form }}`) buff := new(strings.Builder) tpl.Execute(buff, map[string]any{ "Form": form, }) fmt.Println(gohtml.Format(buff.String())) Test me Run Try it yourself ↗ Share ↗ Other helper functions are available to render specific parts of the form:" /><link rel="canonical" href="https://deblan.gitnet.page/go-form/docs/rendering/" itemprop="url" />
|
||||
|
||||
<meta property="og:title" content="Rendering" />
|
||||
<meta property="og:description" content="Creating and processing HTML forms in golang" />
|
||||
|
|
@ -21,12 +21,12 @@ myForm := form.NewForm(...) render := theme.NewRenderer(theme.Bootstrap5) tpl, _
|
|||
|
||||
<meta itemprop="name" content="Rendering">
|
||||
<meta itemprop="description" content="go-form allows you to render a form using Go’s built-in template engine. Here is a simple example that displays a form:
|
||||
myForm := form.NewForm(...) render := theme.NewRenderer(theme.Bootstrap5) tpl, _ := template.New("page").Funcs(render.FuncMap()).Parse(` <html> <head> <title>My form</title> </head> <body> {{ form .Form }} </body> </html> `) b := new(strings.Builder) tpl.Execute(w, map[string]any{ "Form": myForm, }) fmt.Println(b.String()) @import "fmt" @import "html/template" @import "strings" @import @import "github.com/yosssi/gohtml" @import "gitnet.fr/deblan/go-form/example" @import "gitnet.fr/deblan/go-form/theme" form := example.CreateDataForm() render := theme.NewRenderer(theme.Bootstrap5) tpl, _ := template.New("page").Funcs(render.FuncMap()).Parse(`{{ form .Form }}`) buff := new(strings.Builder) tpl.Execute(buff, map[string]any{ "Form": form, }) fmt.Println(gohtml.Format(buff.String())) Test me Run Try it yourself ↗ Share ↗ Other helper functions are available to render specific parts of the form:">
|
||||
<meta itemprop="wordCount" content="151">
|
||||
myForm := form.NewForm(...) render := theme.NewRenderer(theme.Bootstrap5) tpl, _ := template.New("page").Funcs(render.FuncMap()).Parse(` <html> <head> <title>My form</title> </head> <body> {{ form .Form }} </body> </html> `) b := new(strings.Builder) tpl.Execute(w, map[string]any{ "Form": myForm, }) fmt.Println(b.String()) @import "fmt" @import "html/template" @import "strings" @import @import "github.com/yosssi/gohtml" @import "gitnet.fr/deblan/go-form/example" @import "gitnet.fr/deblan/go-form/theme" form := example.CreateDataForm() render := theme.NewRenderer(theme.Html5) // render := theme.NewRenderer(theme.Bootstrap5) tpl, _ := template.New("page").Funcs(render.FuncMap()).Parse(`{{ form .Form }}`) buff := new(strings.Builder) tpl.Execute(buff, map[string]any{ "Form": form, }) fmt.Println(gohtml.Format(buff.String())) Test me Run Try it yourself ↗ Share ↗ Other helper functions are available to render specific parts of the form:">
|
||||
<meta itemprop="wordCount" content="155">
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:title" content="Rendering">
|
||||
<meta name="twitter:description" content="go-form allows you to render a form using Go’s built-in template engine. Here is a simple example that displays a form:
|
||||
myForm := form.NewForm(...) render := theme.NewRenderer(theme.Bootstrap5) tpl, _ := template.New("page").Funcs(render.FuncMap()).Parse(` <html> <head> <title>My form</title> </head> <body> {{ form .Form }} </body> </html> `) b := new(strings.Builder) tpl.Execute(w, map[string]any{ "Form": myForm, }) fmt.Println(b.String()) @import "fmt" @import "html/template" @import "strings" @import @import "github.com/yosssi/gohtml" @import "gitnet.fr/deblan/go-form/example" @import "gitnet.fr/deblan/go-form/theme" form := example.CreateDataForm() render := theme.NewRenderer(theme.Bootstrap5) tpl, _ := template.New("page").Funcs(render.FuncMap()).Parse(`{{ form .Form }}`) buff := new(strings.Builder) tpl.Execute(buff, map[string]any{ "Form": form, }) fmt.Println(gohtml.Format(buff.String())) Test me Run Try it yourself ↗ Share ↗ Other helper functions are available to render specific parts of the form:">
|
||||
myForm := form.NewForm(...) render := theme.NewRenderer(theme.Bootstrap5) tpl, _ := template.New("page").Funcs(render.FuncMap()).Parse(` <html> <head> <title>My form</title> </head> <body> {{ form .Form }} </body> </html> `) b := new(strings.Builder) tpl.Execute(w, map[string]any{ "Form": myForm, }) fmt.Println(b.String()) @import "fmt" @import "html/template" @import "strings" @import @import "github.com/yosssi/gohtml" @import "gitnet.fr/deblan/go-form/example" @import "gitnet.fr/deblan/go-form/theme" form := example.CreateDataForm() render := theme.NewRenderer(theme.Html5) // render := theme.NewRenderer(theme.Bootstrap5) tpl, _ := template.New("page").Funcs(render.FuncMap()).Parse(`{{ form .Form }}`) buff := new(strings.Builder) tpl.Execute(buff, map[string]any{ "Form": form, }) fmt.Println(gohtml.Format(buff.String())) Test me Run Try it yourself ↗ Share ↗ Other helper functions are available to render specific parts of the form:">
|
||||
|
||||
<link rel="preload" href="/go-form/css/compiled/main.min.e0bb0f28123bf084d555fc9253c6d2aa1443b2dfcde6044741a207eabdc3ddb8.css" as="style" integrity="sha256-4LsPKBI78ITVVfySU8bSqhRDst/N5gRHQaIH6r3D3bg=" />
|
||||
<link href="/go-form/css/compiled/main.min.e0bb0f28123bf084d555fc9253c6d2aa1443b2dfcde6044741a207eabdc3ddb8.css" rel="stylesheet" integrity="sha256-4LsPKBI78ITVVfySU8bSqhRDst/N5gRHQaIH6r3D3bg=" />
|
||||
|
|
@ -355,7 +355,8 @@ Here is a simple example that displays a form:</p>
|
|||
@import "gitnet.fr/deblan/go-form/theme"
|
||||
|
||||
form := example.CreateDataForm()
|
||||
render := theme.NewRenderer(theme.Bootstrap5)
|
||||
render := theme.NewRenderer(theme.Html5)
|
||||
// render := theme.NewRenderer(theme.Bootstrap5)
|
||||
|
||||
tpl, _ := template.New("page").Funcs(render.FuncMap()).Parse(`{{ form .Form }}`)
|
||||
|
||||
|
|
@ -369,16 +370,16 @@ fmt.Println(gohtml.Format(buff.String()))
|
|||
</pre>
|
||||
<details>
|
||||
<summary class="hugo-goplay-summary">Test me</summary>
|
||||
<textarea class="hugo-goplay-textarea" id="textarea-d82b883c721a51b71fe97bbd6331c984"></textarea>
|
||||
<div id="d82b883c721a51b71fe97bbd6331c984" class="hugo-goplay-result"></div>
|
||||
<textarea class="hugo-goplay-textarea" id="textarea-b4c457542ee01705b336b3d98eb31f2f"></textarea>
|
||||
<div id="b4c457542ee01705b336b3d98eb31f2f" class="hugo-goplay-result"></div>
|
||||
<div class="hugo-goplay-toolbox">
|
||||
<button role="button" class="hugo-goplay-button" id="hugo-goplay-tool-d82b883c721a51b71fe97bbd6331c984-run">
|
||||
<button role="button" class="hugo-goplay-button" id="hugo-goplay-tool-b4c457542ee01705b336b3d98eb31f2f-run">
|
||||
Run
|
||||
</button>
|
||||
<button role="button" class="hugo-goplay-button" id="hugo-goplay-tool-d82b883c721a51b71fe97bbd6331c984-try">
|
||||
<button role="button" class="hugo-goplay-button" id="hugo-goplay-tool-b4c457542ee01705b336b3d98eb31f2f-try">
|
||||
Try it yourself ↗
|
||||
</button>
|
||||
<button role="button" class="hugo-goplay-button" id="hugo-goplay-tool-d82b883c721a51b71fe97bbd6331c984-share">
|
||||
<button role="button" class="hugo-goplay-button" id="hugo-goplay-tool-b4c457542ee01705b336b3d98eb31f2f-share">
|
||||
Share ↗
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -388,8 +389,8 @@ fmt.Println(gohtml.Format(buff.String()))
|
|||
|
||||
createPlaygroundWithAutoImportMail(
|
||||
new GoPlayProxy("https://gp.deblan.gitnet.page"),
|
||||
"d82b883c721a51b71fe97bbd6331c984",
|
||||
"\n\u003cpre class=\u0022hidden\u0022\u003e\n@import \u0022fmt\u0022\n@import \u0022html\/template\u0022\n@import \u0022strings\u0022\n@import\n@import \u0022github.com\/yosssi\/gohtml\u0022\n@import \u0022gitnet.fr\/deblan\/go-form\/example\u0022\n@import \u0022gitnet.fr\/deblan\/go-form\/theme\u0022\n\nform := example.CreateDataForm()\nrender := theme.NewRenderer(theme.Bootstrap5)\n\ntpl, _ := template.New(\u0022page\u0022).Funcs(render.FuncMap()).Parse(\u0060{{ form .Form }}\u0060)\n\nbuff := new(strings.Builder)\n\ntpl.Execute(buff, map[string]any{\n \u0022Form\u0022: form,\n})\n\nfmt.Println(gohtml.Format(buff.String()))\n\u003c\/pre\u003e\n"
|
||||
"b4c457542ee01705b336b3d98eb31f2f",
|
||||
"\n\u003cpre class=\u0022hidden\u0022\u003e\n@import \u0022fmt\u0022\n@import \u0022html\/template\u0022\n@import \u0022strings\u0022\n@import\n@import \u0022github.com\/yosssi\/gohtml\u0022\n@import \u0022gitnet.fr\/deblan\/go-form\/example\u0022\n@import \u0022gitnet.fr\/deblan\/go-form\/theme\u0022\n\nform := example.CreateDataForm()\nrender := theme.NewRenderer(theme.Html5)\n\/\/ render := theme.NewRenderer(theme.Bootstrap5)\n\ntpl, _ := template.New(\u0022page\u0022).Funcs(render.FuncMap()).Parse(\u0060{{ form .Form }}\u0060)\n\nbuff := new(strings.Builder)\n\ntpl.Execute(buff, map[string]any{\n \u0022Form\u0022: form,\n})\n\nfmt.Println(gohtml.Format(buff.String()))\n\u003c\/pre\u003e\n"
|
||||
)
|
||||
</script>
|
||||
<p>Other helper functions are available to render specific parts of the form:</p>
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue