mirror of
https://github.com/onyx-and-iris/ignr.git
synced 2025-07-26 22:01:57 +00:00
20 lines
548 B
Go
20 lines
548 B
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
// filterFunc returns a function that filters templates based on the specified filter type.
|
|
func filterFunc(templates []string, filterType string) func(input string, index int) bool {
|
|
switch filterType {
|
|
case "contains":
|
|
return func(input string, index int) bool {
|
|
return strings.Contains(strings.ToLower(templates[index]), strings.ToLower(input))
|
|
}
|
|
default:
|
|
return func(input string, index int) bool {
|
|
return strings.HasPrefix(strings.ToLower(templates[index]), strings.ToLower(input))
|
|
}
|
|
}
|
|
}
|