Merge pull request #4943 from pathawks/fp/fix-layout-var-overflow
Merge pull request 4943
This commit is contained in:
		
						commit
						0ca45a48e5
					
				|  | @ -35,3 +35,36 @@ Feature: Layout data | |||
|     When I run jekyll build | ||||
|     Then the "_site/index.html" file should exist | ||||
|     And I should see "page content\n foo: my custom data" in "_site/index.html" | ||||
| 
 | ||||
|   Scenario: Inherit custom layout data and clear when not present | ||||
|     Given I have a _layouts directory | ||||
|     And I have a "_layouts/default.html" file with content: | ||||
|       """ | ||||
|       --- | ||||
|       bar: i'm default | ||||
|       --- | ||||
|       {{ content }} foo: '{{ layout.foo }}' bar: '{{ layout.bar }}' | ||||
|       """ | ||||
|     And I have a "_layouts/special.html" file with content: | ||||
|       """ | ||||
|       --- | ||||
|       layout: default | ||||
|       foo: my special data | ||||
|       bar: im special | ||||
|       --- | ||||
|       {{ content }} | ||||
|       """ | ||||
|     And I have a "_layouts/page.html" file with content: | ||||
|       """ | ||||
|       --- | ||||
|       layout: default | ||||
|       bar: im page | ||||
|       --- | ||||
|       {{ content }} | ||||
|       """ | ||||
|     And I have an "index.html" page with layout "special" that contains "page content" | ||||
|     And I have an "jekyll.html" page with layout "page" that contains "page content" | ||||
|     When I run jekyll build | ||||
|     Then the "_site/index.html" file should exist | ||||
|     And I should see "page content\n foo: 'my special data' bar: 'im special'" in "_site/index.html" | ||||
|     And I should see "page content\n foo: '' bar: 'im page'" in "_site/jekyll.html" | ||||
|  |  | |||
|  | @ -209,10 +209,13 @@ module Jekyll | |||
| 
 | ||||
|       used = Set.new([layout]) | ||||
| 
 | ||||
|       # Reset the payload layout data to ensure it starts fresh for each page. | ||||
|       payload["layout"] = nil | ||||
| 
 | ||||
|       while layout | ||||
|         Jekyll.logger.debug "Rendering Layout:", path | ||||
|         payload["content"] = output | ||||
|         payload["layout"]  = Utils.deep_merge_hashes(payload["layout"] || {}, layout.data) | ||||
|         payload["layout"]  = Utils.deep_merge_hashes(layout.data, payload["layout"] || {}) | ||||
| 
 | ||||
|         self.output = render_liquid(layout.content, | ||||
|                                     payload, | ||||
|  |  | |||
|  | @ -136,10 +136,13 @@ module Jekyll | |||
| 
 | ||||
|       used   = Set.new([layout]) | ||||
| 
 | ||||
|       # Reset the payload layout data to ensure it starts fresh for each page. | ||||
|       payload["layout"] = nil | ||||
| 
 | ||||
|       while layout | ||||
|         payload['content'] = output | ||||
|         payload['page']    = document.to_liquid | ||||
|         payload['layout']  = Utils.deep_merge_hashes(payload['layout'] || {}, layout.data) | ||||
|         payload['layout']  = Utils.deep_merge_hashes(layout.data, payload["layout"] || {}) | ||||
| 
 | ||||
|         output = render_liquid( | ||||
|           layout.content, | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue