diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index b9f7a93f..905afe57 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -112,11 +112,7 @@ module Jekyll # # Returns the Hash representation of this Convertible. def to_liquid(attrs = nil) - further_data = \ - (attrs || self.class::ATTRIBUTES_FOR_LIQUID).each_with_object({}) do |attribute, hsh| - hsh[attribute] = send(attribute) - end - + further_data = attribute_hash(attrs || self.class::ATTRIBUTES_FOR_LIQUID) Utils.deep_merge_hashes defaults, Utils.deep_merge_hashes(data, further_data) end @@ -250,6 +246,13 @@ module Jekyll @defaults ||= site.frontmatter_defaults.all(relative_path, type) end + def attribute_hash(attrs) + @attribute_hash ||= {} + @attribute_hash[attrs] ||= attrs.each_with_object({}) do |attribute, hsh| + hsh[attribute] = send(attribute) + end + end + def no_layout? data["layout"] == "none" end