Disable default layouts for Pages with a `layout: none` declaration (#6182)

Merge pull request 6182
This commit is contained in:
ashmaroli 2017-09-24 01:33:40 +05:30 committed by jekyllbot
parent 023775e4eb
commit e5403396b7
2 changed files with 16 additions and 6 deletions

View File

@ -49,7 +49,7 @@ Feature: Rendering
And I should not see "Ahoy, indeed!" in "_site/index.css"
And I should not see "Ahoy, indeed!" in "_site/index.js"
Scenario: Ignore defaults and don't place documents with layout set to 'none'
Scenario: Ignore defaults and don't place pages and documents with layout set to 'none'
Given I have a "index.md" page with layout "none" that contains "Hi there, {{ site.author }}!"
And I have a _trials directory
And I have a "_trials/no-layout.md" page with layout "none" that contains "Hi there, {{ site.author }}!"
@ -67,9 +67,11 @@ Feature: Rendering
And I should not see "Welcome!" in "_site/trials/no-layout.html"
And I should not see "Check this out!" in "_site/trials/no-layout.html"
But I should see "Check this out!" in "_site/trials/test.html"
And I should see "Welcome!" in "_site/index.html"
And I should see "Hi there, John Doe!" in "_site/index.html"
And I should not see "Welcome!" in "_site/index.html"
And I should not see "Build Warning:" in the build output
Scenario: Don't place documents with layout set to 'none'
Scenario: Don't place pages and documents with layout set to 'none'
Given I have a "index.md" page with layout "none" that contains "Hi there, {{ site.author }}!"
And I have a _trials directory
And I have a "_trials/no-layout.md" page with layout "none" that contains "Hi there, {{ site.author }}!"
@ -84,8 +86,10 @@ Feature: Rendering
Then I should get a zero exit status
And the _site directory should exist
And I should not see "Welcome!" in "_site/trials/no-layout.html"
And I should not see "Welcome!" in "_site/index.html"
But I should see "Check this out!" in "_site/trials/test.html"
And I should see "Welcome!" in "_site/index.html"
And I should see "Hi there, John Doe!" in "_site/index.html"
And I should not see "Build Warning:" in the build output
Scenario: Render liquid in Sass
Given I have an "index.scss" page that contains ".foo-bar { color:{{site.color}}; }"

View File

@ -172,9 +172,10 @@ module Jekyll
# Determine whether the file should be placed into layouts.
#
# Returns false if the document is an asset file.
# Returns false if the document is an asset file or if the front matter
# specifies `layout: none`
def place_in_layout?
!asset_file?
!(asset_file? || no_layout?)
end
# Checks if the layout specified in the document actually exists
@ -244,8 +245,13 @@ module Jekyll
end
private
def _renderer
@_renderer ||= Jekyll::Renderer.new(site, self)
end
def no_layout?
data["layout"] == "none"
end
end
end