Merge pull request #2359 from abroder/where-collection
This commit is contained in:
commit
e278997750
|
@ -94,3 +94,15 @@ Feature: Collections
|
||||||
When I run jekyll build
|
When I run jekyll build
|
||||||
Then the _site directory should exist
|
Then the _site directory should exist
|
||||||
And I should see "First document's output: <p>Use <code>Jekyll.configuration</code> to build a full configuration for use w/Jekyll.</p>\n\n<p>Whatever: foo.bar</p>" in "_site/index.html"
|
And I should see "First document's output: <p>Use <code>Jekyll.configuration</code> to build a full configuration for use w/Jekyll.</p>\n\n<p>Whatever: foo.bar</p>" in "_site/index.html"
|
||||||
|
|
||||||
|
Scenario: Filter documents by where
|
||||||
|
Given I have an "index.html" page that contains "{% assign items = site.methods | where: 'whatever','foo.bar' %}Item count: {{ items.size }}"
|
||||||
|
And I have fixture collections
|
||||||
|
And I have a "_config.yml" file with content:
|
||||||
|
"""
|
||||||
|
collections:
|
||||||
|
- methods
|
||||||
|
"""
|
||||||
|
When I run jekyll build
|
||||||
|
Then the _site directory should exist
|
||||||
|
And I should see "Item count: 1" in "_site/index.html"
|
||||||
|
|
|
@ -185,9 +185,9 @@ module Jekyll
|
||||||
# value - desired value
|
# value - desired value
|
||||||
#
|
#
|
||||||
# Returns the filtered array of objects
|
# Returns the filtered array of objects
|
||||||
def where(input, key, value)
|
def where(input, property, value)
|
||||||
return input unless input.is_a?(Array)
|
return input unless input.is_a?(Array)
|
||||||
input.select { |object| object[key] == value }
|
input.select { |object| item_property(object, property) == value }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sort an array of objects
|
# Sort an array of objects
|
||||||
|
|
Loading…
Reference in New Issue