Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #5398 from Crunch09/liquid-4-collections
[liquid 4] find keys also in assigned collections
  • Loading branch information
parkr committed Sep 22, 2016
2 parents 7bfbd45 + d142e8e commit d3bf7ae
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/jekyll/drops/site_drop.rb
Expand Up @@ -19,6 +19,10 @@ def [](key)
end
end

def key?(key)
(@obj.collections.key?(key) && key != "posts") || super
end

def posts
@site_posts ||= @obj.posts.docs.sort { |a, b| b <=> a }
end
Expand Down
21 changes: 21 additions & 0 deletions test/test_site_drop.rb
@@ -0,0 +1,21 @@
require "helper"

class TestSiteDrop < JekyllUnitTest
context "a site drop" do
setup do
@site = fixture_site({
"collections" => ["thanksgiving"]
})
@site.process
@drop = @site.to_liquid.site
end

should "respond to `key?`" do
assert @drop.respond_to?(:key?)
end

should "find a key if it's in the collection of the drop" do
assert @drop.key?("thanksgiving")
end
end
end

0 comments on commit d3bf7ae

Please sign in to comment.