1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-11-27 06:44:40 +01:00

Move liquid.generics -> evaluator

This commit is contained in:
Oliver Steele 2017-07-05 11:35:20 -04:00
parent 3681f11598
commit 55ac57dcbe
4 changed files with 11 additions and 11 deletions

View File

@ -13,8 +13,8 @@ import (
"github.com/osteele/gojekyll/config" "github.com/osteele/gojekyll/config"
"github.com/osteele/liquid" "github.com/osteele/liquid"
"github.com/osteele/liquid/evaluator"
"github.com/osteele/liquid/expression" "github.com/osteele/liquid/expression"
"github.com/osteele/liquid/generics"
"github.com/russross/blackfriday" "github.com/russross/blackfriday"
) )
@ -47,12 +47,12 @@ func AddJekyllFilters(e liquid.Engine, c config.Config) {
e.RegisterFilter("xml_escape", xml.Marshal) e.RegisterFilter("xml_escape", xml.Marshal)
e.RegisterFilter("push", func(array []interface{}, item interface{}) interface{} { e.RegisterFilter("push", func(array []interface{}, item interface{}) interface{} {
return append(array, generics.MustConvertItem(item, array)) return append(array, evaluator.MustConvertItem(item, array))
}) })
e.RegisterFilter("pop", unimplementedFilter("pop")) e.RegisterFilter("pop", unimplementedFilter("pop"))
e.RegisterFilter("shift", unimplementedFilter("shift")) e.RegisterFilter("shift", unimplementedFilter("shift"))
e.RegisterFilter("unshift", func(array []interface{}, item interface{}) interface{} { e.RegisterFilter("unshift", func(array []interface{}, item interface{}) interface{} {
return append([]interface{}{generics.MustConvertItem(item, array)}, array...) return append([]interface{}{evaluator.MustConvertItem(item, array)}, array...)
}) })
// dates // dates
@ -207,9 +207,9 @@ func sortFilter(array []interface{}, key interface{}, nilFirst interface{}) []in
out := make([]interface{}, len(array)) out := make([]interface{}, len(array))
copy(out, array) copy(out, array)
if key == nil { if key == nil {
generics.Sort(out) evaluator.Sort(out)
} else { } else {
generics.SortByProperty(out, key.(string), nf) evaluator.SortByProperty(out, key.(string), nf)
} }
return out return out
} }

View File

@ -10,7 +10,7 @@ import (
"github.com/osteele/gojekyll/helpers" "github.com/osteele/gojekyll/helpers"
"github.com/osteele/gojekyll/templates" "github.com/osteele/gojekyll/templates"
"github.com/osteele/liquid/generics" "github.com/osteele/liquid/evaluator"
) )
// file is embedded in StaticFile and page // file is embedded in StaticFile and page
@ -85,7 +85,7 @@ func sortedStringValue(field interface{}) []string {
case string: case string:
out = strings.Fields(value) out = strings.Fields(value)
case []interface{}: case []interface{}:
if c, e := generics.Convert(value, reflect.TypeOf(out)); e == nil { if c, e := evaluator.Convert(value, reflect.TypeOf(out)); e == nil {
out = c.([]string) out = c.([]string)
} }
case []string: case []string:

View File

@ -8,7 +8,7 @@ import (
"time" "time"
"github.com/osteele/gojekyll/templates" "github.com/osteele/gojekyll/templates"
"github.com/osteele/liquid/generics" "github.com/osteele/liquid/evaluator"
) )
type page struct { type page struct {
@ -61,7 +61,7 @@ func (p *page) PostDate() time.Time {
case time.Time: case time.Time:
return value return value
case string: case string:
t, err := generics.ParseTime(value) t, err := evaluator.ParseTime(value)
if err == nil { if err == nil {
return t return t
} }

View File

@ -4,7 +4,7 @@ import (
"time" "time"
"github.com/osteele/gojekyll/templates" "github.com/osteele/gojekyll/templates"
"github.com/osteele/liquid/generics" "github.com/osteele/liquid/evaluator"
) )
// ToLiquid returns the site variable for template evaluation. // ToLiquid returns the site variable for template evaluation.
@ -40,7 +40,7 @@ func (s *Site) initializeDrop() {
vars[c.Name] = c.Pages() vars[c.Name] = c.Pages()
collections = append(collections, c.ToLiquid()) collections = append(collections, c.ToLiquid())
} }
generics.SortByProperty(collections, "label", true) evaluator.SortByProperty(collections, "label", true)
vars["collections"] = collections vars["collections"] = collections
s.drop = vars s.drop = vars
s.setPostVariables() s.setPostVariables()