Skip to content

Commit

Permalink
Added contains templating function
Browse files Browse the repository at this point in the history
  • Loading branch information
djthorpe committed Jan 16, 2021
1 parent d8c9ec8 commit 984fef1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/http/handler/tcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ func (this *TemplateCache) funcmap() template.FuncMap {
"pathescape": funcPathEscape,
"queryescape": funcQueryEscape,
"textescape": funcTextEscape,
"contains": funcContains,
}
}

Expand All @@ -198,6 +199,15 @@ func funcTextEscape(value string) string {
return html.EscapeString(value)
}

func funcContains(arr []string, value string) bool {
for _, item := range arr {
if item == value {
return true
}
}
return false
}

func funcSSI(cmd string, args ...string) template.HTML {
switch cmd {
case "block":
Expand Down

0 comments on commit 984fef1

Please sign in to comment.