mirror of
https://github.com/danog/liquid.git
synced 2024-11-30 06:08:57 +01:00
Add concat filter
This commit is contained in:
parent
5cbe290051
commit
87434b73b6
@ -42,6 +42,9 @@ func AddStandardFilters(fd FilterDictionary) { // nolint: gocyclo
|
||||
}
|
||||
return
|
||||
})
|
||||
fd.AddFilter("concat", func(a, b []interface{}) (result []interface{}) {
|
||||
return append(append(result, a...), b...)
|
||||
})
|
||||
fd.AddFilter("join", joinFilter)
|
||||
fd.AddFilter("map", func(a []map[string]interface{}, key string) (result []interface{}) {
|
||||
for _, obj := range a {
|
||||
|
@ -32,6 +32,7 @@ var filterTests = []struct {
|
||||
// array filters
|
||||
{`pages | map: 'category' | join`, "business celebrities lifestyle sports technology"},
|
||||
{`pages | map: 'category' | compact | join`, "business celebrities lifestyle sports technology"},
|
||||
{`"mangos bananas persimmons" | split: " " | concat: fruits | join: ", "`, "mangos, bananas, persimmons, apples, oranges, peaches, plums"},
|
||||
{`"John, Paul, George, Ringo" | split: ", " | join: " and "`, "John and Paul and George and Ringo"},
|
||||
{`",John, Paul, George, Ringo" | split: ", " | join: " and "`, ",John and Paul and George and Ringo"},
|
||||
{`"John, Paul, George, Ringo," | split: ", " | join: " and "`, "John and Paul and George and Ringo,"},
|
||||
|
Loading…
Reference in New Issue
Block a user