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:
@ -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) {
|
||||
|
Reference in New Issue
Block a user