From a5c1a01965e781445f38cac0666d14c17489099b Mon Sep 17 00:00:00 2001 From: Aaron Broder Date: Thu, 8 May 2014 11:35:51 -0700 Subject: [PATCH 1/2] Added item_property to where filter --- lib/jekyll/filters.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/filters.rb b/lib/jekyll/filters.rb index 450e3d78..72d12868 100644 --- a/lib/jekyll/filters.rb +++ b/lib/jekyll/filters.rb @@ -185,9 +185,9 @@ module Jekyll # value - desired value # # Returns the filtered array of objects - def where(input, key, value) + def where(input, property, value) return input unless input.is_a?(Array) - input.select { |object| object[key] == value } + input.select { |object| item_property(object, property) == value } end # Sort an array of objects From f68098c7fc29385a6053dc69f4e35716856148b3 Mon Sep 17 00:00:00 2001 From: Aaron Broder Date: Thu, 8 May 2014 12:04:54 -0700 Subject: [PATCH 2/2] Add test for using where filter on collections --- features/collections.feature | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/features/collections.feature b/features/collections.feature index 821ae64f..8b69ab67 100644 --- a/features/collections.feature +++ b/features/collections.feature @@ -94,3 +94,15 @@ Feature: Collections When I run jekyll build Then the _site directory should exist And I should see "First document's output:

Use Jekyll.configuration to build a full configuration for use w/Jekyll.

\n\n

Whatever: foo.bar

" 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"