1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-11-26 23:34:47 +01:00

Update filter interface

This commit is contained in:
Oliver Steele 2017-07-08 10:29:24 -04:00
parent 62580448b2
commit f1a75669d2
2 changed files with 5 additions and 12 deletions

View File

@ -25,8 +25,7 @@ func intVar(name string, ptr **int) kingpin.Action {
if err != nil {
panic(err)
}
arg := int(n)
*ptr = &arg
*ptr = &n
}
return nil
}

View File

@ -156,11 +156,8 @@ func unimplementedFilter(name string) func(value interface{}) interface{} {
}
}
func arrayToSentenceStringFilter(array []string, conjunction interface{}) string {
conj, ok := conjunction.(string)
if !ok {
conj = "and "
}
func arrayToSentenceStringFilter(array []string, conjunction func(string) string) string {
conj := conjunction("and ")
switch len(array) {
case 1:
return array[0]
@ -208,11 +205,8 @@ func groupByFilter(array []map[string]interface{}, property string) []map[string
return out
}
func sortFilter(array []interface{}, key interface{}, nilFirst interface{}) []interface{} {
nf, ok := nilFirst.(bool)
if !ok {
nf = true
}
func sortFilter(array []interface{}, key interface{}, nilFirst func(bool) bool) []interface{} {
nf := nilFirst(true)
out := make([]interface{}, len(array))
copy(out, array)
if key == nil {