From 26bdcb44ac801647deb4a6b5fd953dcbeb519e90 Mon Sep 17 00:00:00 2001 From: xing Date: Sun, 19 Mar 2023 22:14:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper/html/html.go | 10 +++---- .../theme/wp/components/widget/category.go | 26 +++++++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/helper/html/html.go b/helper/html/html.go index ea598af..e26318e 100644 --- a/helper/html/html.go +++ b/helper/html/html.go @@ -193,19 +193,15 @@ func RenderedHtml(t *template.Template, data map[string]any) (r string, err erro return } -func BuildOptions[T any, K comparable](a []T, selected K, fn func(T) (K, any), attr ...string) string { +func BuildOptions[T any, K comparable](a []T, selected K, fn func(T) (K, any, string)) string { s := strings2.NewBuilder() - att := "" - if len(attr) > 0 { - att = strings.Join(attr, " ") - } for _, t := range a { - k, v := fn(t) + k, v, attr := fn(t) ss := "" if k == selected { ss = "selected" } - s.Sprintf(``, ss, att, v, k) + s.Sprintf(``, ss, attr, v, k) } return s.String() } diff --git a/internal/theme/wp/components/widget/category.go b/internal/theme/wp/components/widget/category.go index bcfbd26..ac563df 100644 --- a/internal/theme/wp/components/widget/category.go +++ b/internal/theme/wp/components/widget/category.go @@ -84,16 +84,27 @@ func categoryUL(h *wp.Handle, args map[string]string, conf map[any]any, categori s := str.NewBuilder() s.WriteString("