Merge pull request #2490 from penibelst/deep-defaults
This commit is contained in:
commit
20180923cf
|
@ -128,3 +128,9 @@ Feature: frontmatter defaults
|
||||||
When I run jekyll build
|
When I run jekyll build
|
||||||
Then the _site directory should exist
|
Then the _site directory should exist
|
||||||
And I should see "Value: Override" in "_site/slides/slide2.html"
|
And I should see "Value: Override" in "_site/slides/slide2.html"
|
||||||
|
|
||||||
|
Scenario: Deep merge frontmatter defaults
|
||||||
|
Given I have an "index.html" page with fruit "{orange: 1}" that contains "Fruits: {{ page.fruit.orange | plus: page.fruit.apple }}"
|
||||||
|
And I have a configuration file with "defaults" set to "[{scope: {path: ""}, values: {fruit: {apple: 2}}}]"
|
||||||
|
When I run jekyll build
|
||||||
|
Then I should see "Fruits: 3" in "_site/index.html"
|
||||||
|
|
|
@ -41,10 +41,10 @@ module Jekyll
|
||||||
old_scope = nil
|
old_scope = nil
|
||||||
matching_sets(path, type).each do |set|
|
matching_sets(path, type).each do |set|
|
||||||
if has_precedence?(old_scope, set['scope'])
|
if has_precedence?(old_scope, set['scope'])
|
||||||
defaults.merge! set['values']
|
defaults = Utils.deep_merge_hashes(defaults, set['values'])
|
||||||
old_scope = set['scope']
|
old_scope = set['scope']
|
||||||
else
|
else
|
||||||
defaults = set['values'].merge(defaults)
|
defaults = Utils.deep_merge_hashes(set['values'], defaults)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
defaults
|
defaults
|
||||||
|
|
Loading…
Reference in New Issue