From 0dc680df0b0ec57a16d8dfd024254b37a3ad2f8f Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 24 Apr 2014 12:50:08 -0400 Subject: [PATCH] Always render collections, just don't always write them --- lib/jekyll/document.rb | 18 +++++++++++------- lib/jekyll/site.rb | 17 +++++------------ test/test_collections.rb | 19 +++++++++++++++++++ 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index ed2005117..0a75fe966 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -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. diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 7a7a27f52..0d6f80fc6 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -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 diff --git a/test/test_collections.rb b/test/test_collections.rb index 8b4c2d230..b6fd41d5b 100644 --- a/test/test_collections.rb +++ b/test/test_collections.rb @@ -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({