mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
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>
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<div class="gt-f1 gt-p-3">
|
||||
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}" title='{{$.ctxData.locale.Tr "repo.issues.attachment.open_tab" .Name}}'>
|
||||
{{if FilenameIsImage .Name}}
|
||||
{{if not (containGeneric $.Content .UUID)}}
|
||||
{{if not (StringUtils.Contains $.Content .UUID)}}
|
||||
{{$hasThumbnails = true}}
|
||||
{{end}}
|
||||
{{svg "octicon-file"}}
|
||||
@@ -29,7 +29,7 @@
|
||||
<div class="ui small thumbnails">
|
||||
{{- range .Attachments -}}
|
||||
{{if FilenameIsImage .Name}}
|
||||
{{if not (containGeneric $.Content .UUID)}}
|
||||
{{if not (StringUtils.Contains $.Content .UUID)}}
|
||||
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}">
|
||||
<img alt="{{.Name}}" src="{{.DownloadURL}}" title='{{$.ctxData.locale.Tr "repo.issues.attachment.open_tab" .Name}}'>
|
||||
</a>
|
||||
|
Reference in New Issue
Block a user