Added comma-delimited string attrib type
This commit is contained in:
@ -39,6 +39,16 @@ func simpleTemplate(paramType, convertExpr string) string {
|
||||
`, paramType, conversion)
|
||||
}
|
||||
|
||||
func listTemplate(separator string) string {
|
||||
return fmt.Sprintf(`func %%s(value ...string) hatmill.Attrib {
|
||||
return hatmill.Attrib{
|
||||
Key: "%%s",
|
||||
Value: strings.Join(value, "%s"),
|
||||
}
|
||||
}
|
||||
`, separator)
|
||||
}
|
||||
|
||||
var attribTypes = map[string]AttribTypeInfo{
|
||||
"string": {Template: simpleTemplate("string", "%s")},
|
||||
"bool": {
|
||||
@ -62,14 +72,12 @@ var attribTypes = map[string]AttribTypeInfo{
|
||||
Imports: []string{"strconv"},
|
||||
},
|
||||
"space list": {
|
||||
Template: `func %s(value ...string) hatmill.Attrib {
|
||||
return hatmill.Attrib{
|
||||
Key: "%s",
|
||||
Value: strings.Join(value, " "),
|
||||
}
|
||||
}
|
||||
`,
|
||||
Imports: []string{"strings"},
|
||||
Template: listTemplate(" "),
|
||||
Imports: []string{"strings"},
|
||||
},
|
||||
"comma list": {
|
||||
Template: listTemplate(","),
|
||||
Imports: []string{"strings"},
|
||||
},
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user