Skip to content

Commit

Permalink
Fix for attr names "accept-charset" and "http-equiv"
Browse files Browse the repository at this point in the history
  • Loading branch information
oderwat committed Jul 28, 2022
1 parent 395258d commit a201a35
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 12 additions & 5 deletions pkg/app/gen/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -2297,6 +2297,13 @@ func writeAttrFunction(w io.Writer, a attr, t tag, isInterface bool) {
fmt.Fprintf(w, "func (e *html%s)", t.Name)
}

var attrName string
if a.NameOverride != "" {
attrName = strings.ToLower(a.NameOverride)
} else {
attrName = strings.ToLower(a.Name)
}

switch a.Type {
case "data|value":
fmt.Fprintf(w, `%s(k string, v any) HTML%s`, a.Name, t.Name)
Expand Down Expand Up @@ -2356,7 +2363,7 @@ func writeAttrFunction(w io.Writer, a attr, t tag, isInterface bool) {
e.setAttr("%s", s)
return e
}`, strings.ToLower(a.Name))
}`, attrName)
}

case "bool|force":
Expand All @@ -2370,7 +2377,7 @@ func writeAttrFunction(w io.Writer, a attr, t tag, isInterface bool) {
e.setAttr("%s", s)
return e
}`, strings.ToLower(a.Name))
}`, attrName)
}

case "url":
Expand All @@ -2379,7 +2386,7 @@ func writeAttrFunction(w io.Writer, a attr, t tag, isInterface bool) {
fmt.Fprintf(w, `{
e.setAttr("%s", v)
return e
}`, strings.ToLower(a.Name))
}`, attrName)
}

case "string|class":
Expand All @@ -2388,7 +2395,7 @@ func writeAttrFunction(w io.Writer, a attr, t tag, isInterface bool) {
fmt.Fprintf(w, `{
e.setAttr("%s", strings.Join(v, " "))
return e
}`, strings.ToLower(a.Name))
}`, attrName)
}

case "xmlns":
Expand All @@ -2406,7 +2413,7 @@ func writeAttrFunction(w io.Writer, a attr, t tag, isInterface bool) {
fmt.Fprintf(w, `{
e.setAttr("%s", v)
return e
}`, strings.ToLower(a.Name))
}`, attrName)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/app/html_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a201a35

Please sign in to comment.