1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-14 22:47:21 +00:00

Refactor template helper (#34819)

FIx abuses and remove unused code

---------

Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
wxiaoguang
2025-06-24 01:27:35 +08:00
committed by GitHub
parent 29b28002aa
commit 327048c106
15 changed files with 20 additions and 39 deletions

View File

@ -7,6 +7,7 @@ import (
"fmt"
"html/template"
"slices"
"strings"
)
// ParseSizeAndClass get size and class from string with default values
@ -31,6 +32,9 @@ func ParseSizeAndClass(defaultSize int, defaultClass string, others ...any) (int
}
func HTMLFormat(s template.HTML, rawArgs ...any) template.HTML {
if !strings.Contains(string(s), "%") || len(rawArgs) == 0 {
panic("HTMLFormat requires one or more arguments")
}
args := slices.Clone(rawArgs)
for i, v := range args {
switch v := v.(type) {