mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
feat: where filter, working on #118
doc: https://shopify.github.io/liquid/filters/where/ ruby impl: https://github.com/Shopify/liquid/blob/14cd011cb5eef042af192ad5294c8f0e1ae89f06/lib/liquid/standardfilters.rb
This commit is contained in:
@@ -64,4 +64,28 @@ describe('filters/array', function () {
|
||||
return test('{{"" | uniq | join: ","}}', '')
|
||||
})
|
||||
})
|
||||
describe('where', function () {
|
||||
it('should support filter by property value', function () {
|
||||
return test(`{% assign kitchen_products = products | where: "type", "kitchen" %}
|
||||
Kitchen products:
|
||||
{% for product in kitchen_products -%}
|
||||
- {{ product.title }}
|
||||
{% endfor %}`, `
|
||||
Kitchen products:
|
||||
- Spatula
|
||||
- Garlic press
|
||||
`)
|
||||
})
|
||||
it('should support filter truthy property', function () {
|
||||
return test(`{% assign available_products = products | where: "available" %}
|
||||
Available products:
|
||||
{% for product in available_products -%}
|
||||
- {{ product.title }}
|
||||
{% endfor %}`, `
|
||||
Available products:
|
||||
- Coffee mug
|
||||
- Boring sneakers
|
||||
`)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user