Skip to content

Commit

Permalink
fix: change "input" tag to "name"
Browse files Browse the repository at this point in the history
this should align with issue #6
  • Loading branch information
crhntr committed Aug 30, 2024
1 parent 3e9b502 commit aa996a1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/muxt/testdata/generate/form.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var templates = template.Must(template.ParseFS(formHTML, "*"))

type Form struct {
Count []int `json:"count"`
Str string `input:"some-string" json:"str"`
Str string `name:"some-string" json:"str"`
}

type T struct {
Expand Down
4 changes: 3 additions & 1 deletion generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const (
DefaultRoutesFunctionName = "routes"
DefaultOutputFileName = "template_routes.go"
receiverInterfaceIdent = "RoutesReceiver"

InputAttributeNameStructTag = "name"
)

func Generate(templateNames []TemplateName, _ *template.Template, packageName, templatesVariableName, routesFunctionName, receiverTypeIdent, output string, fileSet *token.FileSet, receiverPackage, templatesPackage []*ast.File, log *log.Logger) (string, error) {
Expand Down Expand Up @@ -339,7 +341,7 @@ func formInputName(field *ast.Field, name *ast.Ident) string {
if field.Tag != nil {
v, _ := strconv.Unquote(field.Tag.Value)
tags := reflect.StructTag(v)
n, hasInputTag := tags.Lookup("input")
n, hasInputTag := tags.Lookup(InputAttributeNameStructTag)
if hasInputTag {
return n
}
Expand Down
2 changes: 1 addition & 1 deletion generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ package main
type (
T struct{}
In struct{
field string ` + "`input:\"some-field\"`" + `
field string ` + "`name:\"some-field\"`" + `
}
)
Expand Down

0 comments on commit aa996a1

Please sign in to comment.