/p/jeronimoalbi/mdform
Directory ยท 5 Files
Markdown Form Package
The package provides a very simplistic Gno-Flavored Markdown form generator.
Forms can be created by sequentially calling form methods to create each one of the form fields.
Example usage:
1import "gno.land/p/jeronimoalbi/mdform"
2
3func Render(string) string {
4 form := mdform.New()
5
6 // Add a text input field
7 form.Input(
8 "name",
9 "placeholder", "Name",
10 "value", "John Doe",
11 )
12
13 // Add a select field with three possible values
14 form.Select(
15 "country",
16 "United States",
17 "description", "Select your country",
18 )
19 form.Select(
20 "country",
21 "Spain",
22 )
23 form.Select(
24 "country",
25 "Germany",
26 )
27
28 // Add a checkbox group with two possible values
29 form.Checkbox(
30 "interests",
31 "music",
32 "description", "What do you like to do?",
33 )
34 form.Checkbox(
35 "interests",
36 "tech",
37 "checked", "true",
38 )
39
40 return form.String()
41}
Form output:
1<gno-form exec="FunctionName">
2 <gno-input name="name" placeholder="Name" value="John Doe" />
3 <gno-select name="country" value="United States" description="Select your country" />
4 <gno-select name="country" value="Spain" />
5 <gno-select name="country" value="Germany" />
6 <gno-input type="checkbox" name="interests" value="music" description="What do you like to do?" />
7 <gno-input type="checkbox" name="interests" value="tech" checked="true" />
8</gno-form>