From 37a7236e20b5b671e1e609501afe0ddec64a83f3 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Wed, 2 Apr 2014 17:17:55 -0400 Subject: [PATCH] Homagah it all renders I think. --- features/collections.feature | 18 ++++++++++++++++-- lib/jekyll/renderer.rb | 3 ++- lib/jekyll/site.rb | 22 ++++++++-------------- test/source/_methods/site/generate.md | 3 ++- test/test_collections.rb | 2 +- test/test_document.rb | 5 ++++- 6 files changed, 33 insertions(+), 20 deletions(-) diff --git a/features/collections.feature b/features/collections.feature index 0abf15e8..4eb526d3 100644 --- a/features/collections.feature +++ b/features/collections.feature @@ -7,7 +7,7 @@ Feature: Collections Given I have an "index.html" page that contains "Collections: {{ site.collections }}" And I have fixture collections And I have a configuration file with "collections" set to "['methods']" - When I debug jekyll + When I run jekyll Then the _site directory should exist And I should see "Collections: {\"methods\"=>#, #, #, #, #\]>}" in "_site/index.html" @@ -21,4 +21,18 @@ Feature: Collections When I run jekyll Then the _site directory should exist And I should see "Collections: methods" in "_site/index.html" - And I should see "Whatever: foo.bar" in "_site/methods/configuration.html" \ No newline at end of file + And I should see "

Whatever: foo.bar

" in "_site/methods/configuration.html" + + Scenario: Rendered document in a layout + Given I have an "index.html" page that contains "Collections: {{ site.collections.methods.label }}" + And I have a default layout that contains "
Tom Preston-Werner
{{content}}" + And I have fixture collections + And I have a configuration file with: + | key | value | + | collections | ['methods'] | + | render | ['methods'] | + When I run jekyll + Then the _site directory should exist + And I should see "Collections: methods" in "_site/index.html" + And I should see "

Run your generators! default

" in "_site/methods/site/generate.html" + And I should see "
Tom Preston-Werner
" in "_site/methods/site/generate.html" \ No newline at end of file diff --git a/lib/jekyll/renderer.rb b/lib/jekyll/renderer.rb index 568619d7..0fb7b7f1 100644 --- a/lib/jekyll/renderer.rb +++ b/lib/jekyll/renderer.rb @@ -31,6 +31,7 @@ module Jekyll payload = Utils.deep_merge_hashes({ "page" => document.to_liquid }, site.site_payload) + info = { filters: [Jekyll::Filters], registers: { :site => site, :page => payload['page'] } @@ -117,7 +118,7 @@ module Jekyll File.join(site.config['layouts'], layout.name) ) - if layout = layouts[layout.data["layout"]] + if layout = site.layouts[layout.data["layout"]] if used.include?(layout) layout = nil # avoid recursive chain else diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 1c036939..2bdf1898 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -92,7 +92,7 @@ module Jekyll end end - def render + def to_render config['render'] || Array.new end @@ -197,9 +197,7 @@ module Jekyll # # Returns nothing. def read_collections - if collections - collections.each { |_, collection| collection.read } - end + collections.each { |_, collection| collection.read } end # Run each of the Generators. @@ -217,11 +215,9 @@ module Jekyll def render relative_permalinks_deprecation_method - if collections - collections.each do |label, collection| - collection.docs.each do |document| - document.output = Jekyll::Renderer.new(self, document).run - end + collections.each do |label, collection| + collection.docs.each do |document| + document.output = Jekyll::Renderer.new(self, document).run end end @@ -389,11 +385,9 @@ module Jekyll def documents docs = Set.new - if collections - collections.each do |label, coll| - if render.include?(label) - docs = docs.merge(coll.docs) - end + collections.each do |label, coll| + if to_render.include?(label) + docs = docs.merge(coll.docs) end end docs diff --git a/test/source/_methods/site/generate.md b/test/source/_methods/site/generate.md index b7eaaf62..1cab376e 100644 --- a/test/source/_methods/site/generate.md +++ b/test/source/_methods/site/generate.md @@ -1,5 +1,6 @@ --- title: "Site#generate" +layout: default --- -Run your generators! +Run your generators! {{ page.layout }} diff --git a/test/test_collections.rb b/test/test_collections.rb index afe8bd06..06120790 100644 --- a/test/test_collections.rb +++ b/test/test_collections.rb @@ -12,7 +12,7 @@ class TestCollections < Test::Unit::TestCase end should "not contain any collections" do - assert_nil @site.collections + assert_equal @site.collections, Hash.new end end diff --git a/test/test_document.rb b/test/test_document.rb index 75bf2a84..794c2117 100644 --- a/test/test_document.rb +++ b/test/test_document.rb @@ -2,7 +2,7 @@ require 'helper' class TestDocument < Test::Unit::TestCase - context "" do + context "a document in a collection" do setup do @site = Site.new(Jekyll.configuration({ "collections" => ["methods"], @@ -42,4 +42,7 @@ class TestDocument < Test::Unit::TestCase end + context " a document part of a rendered collection" do + end + end