]> source.dussan.org Git - gitea.git/commit
Improve template helper functions: string/slice (#24266)
authorwxiaoguang <wxiaoguang@gmail.com>
Sat, 22 Apr 2023 18:16:22 +0000 (02:16 +0800)
committerGitHub <noreply@github.com>
Sat, 22 Apr 2023 18:16:22 +0000 (14:16 -0400)
commit88201914767e15a51c910d295647d97973fa09bf
tree460ac508dc67089db99877d5394db98844283f27
parentc0d105609f120839c91679b0548b9438155c4bba
Improve template helper functions: string/slice (#24266)

Follow #23328

The improvements:

1. The `contains` functions are covered by tests
2. The inconsistent behavior of `containGeneric` is replaced by
`StringUtils.Contains` and `SliceUtils.Contains`
3. In the future we can move more help functions into XxxUtils to
simplify the `helper.go` and reduce unnecessary global functions.

FAQ:

1. Why it's called `StringUtils.Contains` but not `strings.Contains`
like Golang?

Because our `StringUtils` is not Golang's `strings` package. There will
be our own string functions.

---------

Co-authored-by: silverwind <me@silverwind.io>
12 files changed:
modules/templates/helper.go
modules/templates/util.go [deleted file]
modules/templates/util_dict.go [new file with mode: 0644]
modules/templates/util_slice.go [new file with mode: 0644]
modules/templates/util_string.go [new file with mode: 0644]
modules/templates/util_test.go
templates/repo/graph/commits.tmpl
templates/repo/header.tmpl
templates/repo/issue/list.tmpl
templates/repo/issue/milestone_issues.tmpl
templates/repo/issue/view_content/attachments.tmpl
templates/repo/settings/tags.tmpl