Added space-delimited string list attrib type

This commit is contained in:
2019-05-29 21:32:16 -06:00
parent d24afba75c
commit 69b1e1644d
4 changed files with 34 additions and 21 deletions

View File

@ -4,6 +4,7 @@
package attribute
import "gitlab.codemonkeysoftware.net/b/hatmill"
import "strings"
import "strconv"
// Accept sets the content types or file types allowed in a form or file input.
@ -15,10 +16,10 @@ func Accept(value string) hatmill.Attrib {
}
// AcceptCharset creates a "accept-charset" attribute
func AcceptCharset(value string) hatmill.Attrib {
func AcceptCharset(value ...string) hatmill.Attrib {
return hatmill.Attrib{
Key: "accept-charset",
Value: value,
Value: strings.Join(value, " "),
}
}
@ -99,10 +100,10 @@ func Cite(value string) hatmill.Attrib {
}
// Class creates a "class" attribute
func Class(value string) hatmill.Attrib {
func Class(value ...string) hatmill.Attrib {
return hatmill.Attrib{
Key: "class",
Value: value,
Value: strings.Join(value, " "),
}
}
@ -247,10 +248,10 @@ func Enctype(value string) hatmill.Attrib {
}
// For creates a "for" attribute
func For(value string) hatmill.Attrib {
func For(value ...string) hatmill.Attrib {
return hatmill.Attrib{
Key: "for",
Value: value,
Value: strings.Join(value, " "),
}
}
@ -279,10 +280,10 @@ func Formmethod(value string) hatmill.Attrib {
}
// Headers creates a "headers" attribute
func Headers(value string) hatmill.Attrib {
func Headers(value ...string) hatmill.Attrib {
return hatmill.Attrib{
Key: "headers",
Value: value,
Value: strings.Join(value, " "),
}
}
@ -504,10 +505,10 @@ func Pattern(value string) hatmill.Attrib {
}
// Ping creates a "ping" attribute
func Ping(value string) hatmill.Attrib {
func Ping(value ...string) hatmill.Attrib {
return hatmill.Attrib{
Key: "ping",
Value: value,
Value: strings.Join(value, " "),
}
}
@ -551,10 +552,10 @@ func Referrerpolicy(value string) hatmill.Attrib {
}
// Rel creates a "rel" attribute
func Rel(value string) hatmill.Attrib {
func Rel(value ...string) hatmill.Attrib {
return hatmill.Attrib{
Key: "rel",
Value: value,
Value: strings.Join(value, " "),
}
}
@ -589,10 +590,10 @@ func Rowspan(value int) hatmill.Attrib {
}
// Sandbox creates a "sandbox" attribute
func Sandbox(value string) hatmill.Attrib {
func Sandbox(value ...string) hatmill.Attrib {
return hatmill.Attrib{
Key: "sandbox",
Value: value,
Value: strings.Join(value, " "),
}
}