From 31ae61b419fd422b7384ab006e66814b00532657 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 21 Jan 2016 18:20:35 -0800 Subject: [PATCH] Drop#[]: only use public_send for keys in the content_methods array --- features/post_data.feature | 12 ++++++++++++ lib/jekyll/drops/drop.rb | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/features/post_data.feature b/features/post_data.feature index 3692c382..79b92c26 100644 --- a/features/post_data.feature +++ b/features/post_data.feature @@ -301,6 +301,18 @@ Feature: Post data And the _site directory should exist And I should see "Post author: Darth Vader" in "_site/2009/03/27/star-wars.html" + Scenario: Use a variable which is a reserved keyword in Ruby + Given I have a _posts directory + And I have a _layouts directory + And I have the following post: + | title | date | layout | class | content | + | My post | 2016-01-21 | simple | kewl-post | Luke, I am your father. | + And I have a simple layout that contains "{{page.title}} has class {{page.class}}" + When I run jekyll build + Then I should get a zero exit status + And the _site directory should exist + And I should see "My post has class kewl-post" in "_site/2016/01/21/my-post.html" + Scenario: Previous and next posts title Given I have a _posts directory And I have a _layouts directory diff --git a/lib/jekyll/drops/drop.rb b/lib/jekyll/drops/drop.rb index 35f0df26..9e3ac329 100644 --- a/lib/jekyll/drops/drop.rb +++ b/lib/jekyll/drops/drop.rb @@ -46,7 +46,7 @@ module Jekyll def [](key) if self.class.mutable? && @mutations.key?(key) @mutations[key] - elsif respond_to? key + elsif content_methods.include? key public_send key else fallback_data[key]