-
-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add type
attribute to Document instances
#7406
Conversation
Profiler summary--- master branch https://travis-ci.org/jekyll/jekyll/jobs/532959217
+++ PR branch https://travis-ci.org/jekyll/jekyll/jobs/533140377
- Total allocated: 532.65 MB (5301707 objects)
- Total retained: 18.34 MB (96237 objects)
+ Total allocated: 532.4 MB (5296981 objects)
+ Total retained: 18.33 MB (95977 objects) |
@@ -39,7 +41,7 @@ def initialize(path, relations = {}) | |||
end | |||
|
|||
data.default_proc = proc do |_, key| | |||
site.frontmatter_defaults.find(relative_path, collection.label, key) | |||
site.frontmatter_defaults.find(relative_path, type, key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was collection.label
already a symbol? If not, is our replacing it with a symbol here safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is safe because, it is expected (from the comments):
jekyll/lib/jekyll/frontmatter_defaults.rb
Lines 51 to 70 in b82e4ea
# Finds a default value for a given setting, filtered by path and type | |
# | |
# path - the path (relative to the source) of the page, | |
# post or :draft the default is used in | |
# type - a symbol indicating whether a :page, | |
# a :post or a :draft calls this method | |
# | |
# Returns the default value or nil if none was found | |
def find(path, type, setting) | |
value = nil | |
old_scope = nil | |
matching_sets(path, type).each do |set| | |
if set["values"].key?(setting) && has_precedence?(old_scope, set["scope"]) | |
value = set["values"][setting] | |
old_scope = set["scope"] | |
end | |
end | |
value | |
end |
@jekyllbot: merge +minor |
Summary
Jekyll::Page
andJekyll::StaticFile
where instances the latter two classes respond to the:type
method.@doc.collection.label
and@doc.collection.label.to_sym
as is done currently