excerpt drop should give access to document's layout

This commit is contained in:
Parker Moore 2016-05-17 16:58:26 -07:00 committed by Pat Hawks
parent c0910f2bc5
commit 7d3f8ac75d
2 changed files with 11 additions and 2 deletions

View File

@ -3,6 +3,10 @@
module Jekyll module Jekyll
module Drops module Drops
class ExcerptDrop < DocumentDrop class ExcerptDrop < DocumentDrop
def layout
@obj.doc.data['layout']
end
def excerpt def excerpt
nil nil
end end

View File

@ -5,7 +5,7 @@ class TestExcerptDrop < JekyllUnitTest
setup do setup do
@site = fixture_site @site = fixture_site
@site.read @site.read
@doc = @site.docs_to_write.first @doc = @site.docs_to_write.find { |d| !d.data['layout'].nil? }
@doc_drop = @doc.to_liquid @doc_drop = @doc.to_liquid
@excerpt = @doc.data['excerpt'] @excerpt = @doc.data['excerpt']
@excerpt_drop = @excerpt.to_liquid @excerpt_drop = @excerpt.to_liquid
@ -24,8 +24,13 @@ class TestExcerptDrop < JekyllUnitTest
assert_nil @excerpt_drop['excerpt'] assert_nil @excerpt_drop['excerpt']
end end
should "inherit the layout for the drop but not the excerpt" do
assert_nil @excerpt.data['layout']
assert_equal @excerpt_drop['layout'], @doc_drop['layout']
end
should "inherit values from the document" do should "inherit values from the document" do
assert_equal @excerpt_drop.keys, @doc_drop.keys assert_equal @excerpt_drop.keys.sort, @doc_drop.keys.sort
end end
end end
end end