From 3fe9e92c4f3e3bbf2a3dba437e98d08e360a7f50 Mon Sep 17 00:00:00 2001 From: Nathan Hazout Date: Tue, 14 Jun 2016 13:07:26 +0300 Subject: [PATCH 1/2] Prevent reset of page to fix #4414 --- lib/jekyll/renderer.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/jekyll/renderer.rb b/lib/jekyll/renderer.rb index f9eb94be..87f327d6 100644 --- a/lib/jekyll/renderer.rb +++ b/lib/jekyll/renderer.rb @@ -141,7 +141,6 @@ module Jekyll while layout payload['content'] = output - payload['page'] = document.to_liquid payload['layout'] = Utils.deep_merge_hashes(layout.data, payload["layout"] || {}) output = render_liquid( From d1f4d874be4d822ba9c68491bb26a8b7cc3df93d Mon Sep 17 00:00:00 2001 From: Nathan Hazout Date: Wed, 15 Jun 2016 11:21:02 +0300 Subject: [PATCH 2/2] Added a scenario for #4414 --- features/hooks.feature | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/features/hooks.feature b/features/hooks.feature index 48b2884e..075f632a 100644 --- a/features/hooks.feature +++ b/features/hooks.feature @@ -333,3 +333,28 @@ Feature: Hooks Then I should get a zero exit status And the _site directory should exist And I should see "Wrote document 0" in "_site/document-build.log" + + Scenario: Set a custom payload['page'] property + Given I have a _plugins directory + And I have a "_plugins/ext.rb" file with content: + """ + Jekyll::Hooks.register :pages, :pre_render do |page, payload| + payload['page']['foo'] = "hello world" + end + """ + And I have a _layouts directory + And I have a "_layouts/custom.html" file with content: + """ + --- + --- + {{ content }} {% include foo.html %} + """ + And I have a _includes directory + And I have a "_includes/foo.html" file with content: + """ + {{page.foo}} + """ + And I have an "index.html" page with layout "custom" that contains "page content" + When I run jekyll build + Then the "_site/index.html" file should exist + And I should see "page content\n hello world" in "_site/index.html"