From b6621a26e030b3448adcfa8c140060883452db21 Mon Sep 17 00:00:00 2001 From: Bruce Smith Date: Sat, 18 Jan 2025 18:10:23 +1100 Subject: [PATCH 1/2] Update html.go Fix for issue #1016 --- pkg/app/gen/html.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/app/gen/html.go b/pkg/app/gen/html.go index 3cd49a88..a5f48974 100644 --- a/pkg/app/gen/html.go +++ b/pkg/app/gen/html.go @@ -2447,7 +2447,7 @@ func writeAttrFunction(w io.Writer, a attr, t tag, isInterface bool) { if !isInterface { fmt.Fprintf(w, `{ for k, v := range s { - e.Style(k, v) + e.Style(k, "%s", v) } return e }`) From b6ca0f680e82c12feb6dc834ffab4a99ec61c9c7 Mon Sep 17 00:00:00 2001 From: bruceesmith Date: Sun, 19 Jan 2025 15:58:07 +1100 Subject: [PATCH 2/2] Fix a bunch of 'go vet' errors in pkg/app/gen/html.go: pkg/app/gen/html.go:2448:4: fmt.Fprintf format %s reads arg #1, but call has 0 args pkg/app/gen/html.go:2584:5: fmt.Fprintln call has possible Printf formatting directive %v pkg/app/gen/html.go:2610:5: fmt.Fprintln call has possible Printf formatting directive %v pkg/app/gen/html.go:2631:4: fmt.Fprintln call has possible Printf formatting directive %s --- pkg/app/gen/html.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/app/gen/html.go b/pkg/app/gen/html.go index a5f48974..579a3d4c 100644 --- a/pkg/app/gen/html.go +++ b/pkg/app/gen/html.go @@ -2445,9 +2445,10 @@ func writeAttrFunction(w io.Writer, a attr, t tag, isInterface bool) { case "style|map": fmt.Fprintf(w, `%s(s map[string]string) HTML%s`, a.Name, t.Name) if !isInterface { - fmt.Fprintf(w, `{ + style := `e.Style(k, "%s", v)` + fmt.Fprintln(w, `{ for k, v := range s { - e.Style(k, "%s", v) + `+style+` } return e }`) @@ -2581,7 +2582,8 @@ import ( fmt.Fprintln(f, `map[string]any{"foo": "bar"})`) case "style": - fmt.Fprintln(f, `"margin", "%vpx", 42)`) + line := `"margin", "%vpx", 42)` + fmt.Fprintln(f, line) case "style|map": fmt.Fprintln(f, `map[string]string{"color": "pink"})`) @@ -2607,7 +2609,8 @@ import ( fmt.Fprintln(f, `"http://www.w3.org/2000/svg")`) case "fmt": - fmt.Fprintln(f, `"hello %v", 42)`) + line := `"hello %v", 42)` + fmt.Fprintln(f, line) default: fmt.Fprintln(f, `42)`) @@ -2628,7 +2631,8 @@ import ( switch t.Type { case parent: fmt.Fprintln(f, `elem.Text("hello")`) - fmt.Fprintln(f, `elem.Textf("hello %s", "Maxence")`) + line := `elem.Textf("hello %s", "Maxence")` + fmt.Fprintln(f, line) case privateParent: fmt.Fprintln(f, `elem.privateBody(Text("hello"))`)