Added comma-delimited string attrib type
This commit is contained in:
@ -8,10 +8,10 @@ import "strings"
|
||||
import "strconv"
|
||||
|
||||
// Accept sets the content types or file types allowed in a form or file input.
|
||||
func Accept(value string) hatmill.Attrib {
|
||||
func Accept(value ...string) hatmill.Attrib {
|
||||
return hatmill.Attrib{
|
||||
Key: "accept",
|
||||
Value: value,
|
||||
Value: strings.Join(value, ","),
|
||||
}
|
||||
}
|
||||
|
||||
@ -677,10 +677,10 @@ func Srclang(value string) hatmill.Attrib {
|
||||
}
|
||||
|
||||
// Srcset creates a "srcset" attribute
|
||||
func Srcset(value string) hatmill.Attrib {
|
||||
func Srcset(value ...string) hatmill.Attrib {
|
||||
return hatmill.Attrib{
|
||||
Key: "srcset",
|
||||
Value: value,
|
||||
Value: strings.Join(value, ","),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,15 @@ func TestSpaceList(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestCommaList(t *testing.T) {
|
||||
t.Run("empty", func(t *testing.T) {
|
||||
testAttribValue(t, attribute.Class(), "")
|
||||
})
|
||||
t.Run("nonempty", func(t *testing.T) {
|
||||
testAttribValue(t, attribute.Accept("alpha", "bravo", "charlie"), "alpha,bravo,charlie")
|
||||
})
|
||||
}
|
||||
|
||||
func TestString(t *testing.T) {
|
||||
const s = "abcdefg"
|
||||
testAttribValue(t, attribute.Id(s), s)
|
||||
|
Reference in New Issue
Block a user