Added explicit bool attribute type
This commit is contained in:
parent
01d8048892
commit
e0ccb4549e
@ -139,10 +139,10 @@ func Content(value string) hatmill.Attrib {
|
||||
}
|
||||
|
||||
// Contenteditable creates a "contenteditable" attribute
|
||||
func Contenteditable(value string) hatmill.Attrib {
|
||||
func Contenteditable(value bool) hatmill.Attrib {
|
||||
return hatmill.Attrib{
|
||||
Key: "contenteditable",
|
||||
Value: value,
|
||||
Value: strconv.FormatBool(value),
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,10 +239,10 @@ func Download(value string) hatmill.Attrib {
|
||||
}
|
||||
|
||||
// Draggable creates a "draggable" attribute
|
||||
func Draggable(value string) hatmill.Attrib {
|
||||
func Draggable(value bool) hatmill.Attrib {
|
||||
return hatmill.Attrib{
|
||||
Key: "draggable",
|
||||
Value: value,
|
||||
Value: strconv.FormatBool(value),
|
||||
}
|
||||
}
|
||||
|
||||
@ -644,10 +644,10 @@ func Span(value int) hatmill.Attrib {
|
||||
}
|
||||
|
||||
// Spellcheck creates a "spellcheck" attribute
|
||||
func Spellcheck(value string) hatmill.Attrib {
|
||||
func Spellcheck(value bool) hatmill.Attrib {
|
||||
return hatmill.Attrib{
|
||||
Key: "spellcheck",
|
||||
Value: value,
|
||||
Value: strconv.FormatBool(value),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
{"name": "cols", "type": "int"},
|
||||
{"name": "colspan", "type": "int"},
|
||||
{"name": "content", "type": "string"},
|
||||
{"name": "contenteditable", "type": "string"},
|
||||
{"name": "contenteditable", "type": "explicit bool"},
|
||||
{"name": "contextmenu", "type": "string"},
|
||||
{"name": "controls", "type": "bool"},
|
||||
{"name": "coords", "type": "string"},
|
||||
@ -30,7 +30,7 @@
|
||||
{"name": "dirname", "type": "string"},
|
||||
{"name": "disabled", "type": "bool"},
|
||||
{"name": "download", "type": "string"},
|
||||
{"name": "draggable", "type": "string"},
|
||||
{"name": "draggable", "type": "explicit bool"},
|
||||
{"name": "enctype", "type": "string"},
|
||||
{"name": "for", "type": "string"},
|
||||
{"name": "form", "type": "string"},
|
||||
@ -82,7 +82,7 @@
|
||||
{"name": "size", "type": "int"},
|
||||
{"name": "sizes", "type": "string"},
|
||||
{"name": "span", "type": "int"},
|
||||
{"name": "spellcheck", "type": "string"},
|
||||
{"name": "spellcheck", "type": "explicit bool"},
|
||||
{"name": "src", "type": "string"},
|
||||
{"name": "srcdoc", "type": "string"},
|
||||
{"name": "srclang", "type": "string"},
|
||||
|
@ -183,7 +183,7 @@ func Example() {
|
||||
|
||||
document := he.Html()(
|
||||
he.Body()(
|
||||
he.Img(ha.Src("./photo.jpg")),
|
||||
he.Img(ha.Src("./photo.jpg"), ha.Contenteditable(true)),
|
||||
hatmill.Text(html.EscapeString(userInput)),
|
||||
he.Div(ha.Disabled(), ha.CustomData("coolness", "awesome"))(),
|
||||
he.Textarea(ha.Rows(25))(),
|
||||
@ -191,5 +191,5 @@ func Example() {
|
||||
),
|
||||
)
|
||||
hatmill.WriteDocument(os.Stdout, document)
|
||||
// Output: <!DOCTYPE html><html><body><img src='./photo.jpg'><script>launchMissiles();</script><div disabled data-coolness='awesome'></div><textarea rows='25'></textarea><meter min='-1.3' max='5.5E+12'></meter></body></html>
|
||||
// Output: <!DOCTYPE html><html><body><img src='./photo.jpg' contenteditable='true'><script>launchMissiles();</script><div disabled data-coolness='awesome'></div><textarea rows='25'></textarea><meter min='-1.3' max='5.5E+12'></meter></body></html>
|
||||
}
|
||||
|
@ -46,6 +46,18 @@ var attribTypes = map[string]AttribTypeInfo{
|
||||
`,
|
||||
},
|
||||
|
||||
"explicit bool": {
|
||||
Template: `// %[1]s creates a "%[2]s" attribute
|
||||
func %[1]s(value bool) hatmill.Attrib {
|
||||
return hatmill.Attrib{
|
||||
Key: "%[2]s",
|
||||
Value: strconv.FormatBool(value),
|
||||
}
|
||||
}
|
||||
`,
|
||||
Imports: []string{"strconv"},
|
||||
},
|
||||
|
||||
"int": {
|
||||
Template: `// %[1]s creates a "%[2]s" attribute
|
||||
func %[1]s(value int) hatmill.Attrib {
|
||||
|
Loading…
Reference in New Issue
Block a user