Always render collections, just don't always write them

This commit is contained in:
Parker Moore 2014-04-24 12:50:08 -04:00
parent 3a6ad0737c
commit 0dc680df0b
3 changed files with 35 additions and 19 deletions

View File

@ -112,7 +112,7 @@ module Jekyll
#
# Returns the permalink or nil if no permalink was set in the data.
def permalink
data && data['permalink']
data && data.is_a?(Hash) && data['permalink']
end
# The computed URL for the document. See `Jekyll::URL#to_s` for more details.
@ -192,12 +192,16 @@ module Jekyll
#
# Returns a Hash representing this Document's data.
def to_liquid
Utils.deep_merge_hashes data, {
"content" => content,
"path" => path,
"relative_path" => relative_path,
"url" => url
}
if data.is_a?(Hash)
Utils.deep_merge_hashes data, {
"content" => content,
"path" => path,
"relative_path" => relative_path,
"url" => url
}
else
data
end
end
# The inspect string for this document.

View File

@ -111,13 +111,6 @@ module Jekyll
end
end
# The list of collections to render.
#
# The array of collection labels to render.
def to_render
@to_render ||= (config['render'] || Array.new)
end
# Read Site data from disk and load it into internal data structures.
#
# Returns nothing.
@ -240,8 +233,8 @@ module Jekyll
def render
relative_permalinks_deprecation_method
to_render.each do |label|
collections[label].docs.each do |document|
collections.each do |label, collection|
collection.docs.each do |document|
document.output = Jekyll::Renderer.new(self, document).run
end
end
@ -411,9 +404,9 @@ module Jekyll
end
def documents
collections.reduce(Set.new) do |docs, (label, coll)|
if to_render.include?(label)
docs.merge(coll.docs)
collections.reduce(Set.new) do |docs, (_, collection)|
if collection.write?
docs.merge(collection.docs)
else
docs
end

View File

@ -107,6 +107,25 @@ class TestCollections < Test::Unit::TestCase
end
end
context "with a collection with metadata" do
setup do
@site = fixture_site({
"collections" => {
"methods" => {
"foo" => "bar",
"baz" => "whoo"
}
}
})
@site.process
@collection = @site.collections["methods"]
end
should "extract the configuration collection information as metadata" do
assert_equal @collection.metadata, {"foo" => "bar", "baz" => "whoo"}
end
end
context "in safe mode" do
setup do
@site = fixture_site({