Stash attribute hash for Liquid computed for pages (#8497)

Merge pull request 8497
This commit is contained in:
Ashwin Maroli 2020-12-10 19:30:23 +05:30 committed by GitHub
parent c70437e2de
commit 01825f51db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 5 deletions

View File

@ -112,11 +112,7 @@ module Jekyll
# #
# Returns the Hash representation of this Convertible. # Returns the Hash representation of this Convertible.
def to_liquid(attrs = nil) def to_liquid(attrs = nil)
further_data = \ further_data = attribute_hash(attrs || self.class::ATTRIBUTES_FOR_LIQUID)
(attrs || self.class::ATTRIBUTES_FOR_LIQUID).each_with_object({}) do |attribute, hsh|
hsh[attribute] = send(attribute)
end
Utils.deep_merge_hashes defaults, Utils.deep_merge_hashes(data, further_data) Utils.deep_merge_hashes defaults, Utils.deep_merge_hashes(data, further_data)
end end
@ -250,6 +246,13 @@ module Jekyll
@defaults ||= site.frontmatter_defaults.all(relative_path, type) @defaults ||= site.frontmatter_defaults.all(relative_path, type)
end 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? def no_layout?
data["layout"] == "none" data["layout"] == "none"
end end