Merge pull request #2431 from jekyll/remove-collections-from-layouts
This commit is contained in:
commit
65275e5841
|
@ -0,0 +1,34 @@
|
||||||
|
Feature: Rendering
|
||||||
|
As a hacker who likes to blog
|
||||||
|
I want to be able to make a static site
|
||||||
|
In order to share my awesome ideas with the interwebs
|
||||||
|
But I want to make it as simply as possible
|
||||||
|
So render with Liquid and place in Layouts
|
||||||
|
|
||||||
|
Scenario: Render Liquid and place in layout
|
||||||
|
Given I have a "index.html" page with layout "simple" that contains "Hi there, Jekyll {{ jekyll.environment }}!"
|
||||||
|
And I have a simple layout that contains "{{ content }}Ahoy, indeed!"
|
||||||
|
When I run jekyll build
|
||||||
|
Then the _site directory should exist
|
||||||
|
And I should see "Hi there, Jekyll development!\nAhoy, indeed" in "_site/index.html"
|
||||||
|
|
||||||
|
Scenario: Don't place asset files in layout
|
||||||
|
Given I have an "index.scss" page with layout "simple" that contains ".foo-bar { color:black; }"
|
||||||
|
And I have an "index.coffee" page with layout "simple" that contains "whatever()"
|
||||||
|
And I have a simple layout that contains "{{ content }}Ahoy, indeed!"
|
||||||
|
When I run jekyll build
|
||||||
|
Then the _site directory should exist
|
||||||
|
And I should not see "Ahoy, indeed!" in "_site/index.css"
|
||||||
|
And I should not see "Ahoy, indeed!" in "_site/index.js"
|
||||||
|
|
||||||
|
Scenario: Don't render liquid in Sass
|
||||||
|
Given I have an "index.scss" page that contains ".foo-bar { color:{{site.color}}; }"
|
||||||
|
When I run jekyll build
|
||||||
|
Then the _site directory should not exist
|
||||||
|
And I should see "Invalid CSS after" in the build output
|
||||||
|
|
||||||
|
Scenario: Don't render liquid in CoffeeScript
|
||||||
|
Given I have an "index.coffee" page that contains "hey='for {{site.animal}}'"
|
||||||
|
When I run jekyll build
|
||||||
|
Then the _site directory should exist
|
||||||
|
And I should see "hey = 'for {{site.animal}}';" in "_site/index.js"
|
|
@ -141,7 +141,7 @@ end
|
||||||
|
|
||||||
When /^I run jekyll(.*)$/ do |args|
|
When /^I run jekyll(.*)$/ do |args|
|
||||||
status = run_jekyll(args)
|
status = run_jekyll(args)
|
||||||
if !status || args.include?("--verbose")
|
if args.include?("--verbose")
|
||||||
puts jekyll_run_output
|
puts jekyll_run_output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -195,3 +195,7 @@ end
|
||||||
Then /^I should see today's date in "(.*)"$/ do |file|
|
Then /^I should see today's date in "(.*)"$/ do |file|
|
||||||
assert_match Regexp.new(Date.today.to_s), file_contents(file)
|
assert_match Regexp.new(Date.today.to_s), file_contents(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Then /^I should see "(.*)" in the build output$/ do |text|
|
||||||
|
assert_match Regexp.new(text), jekyll_run_output
|
||||||
|
end
|
||||||
|
|
|
@ -114,6 +114,10 @@ module Jekyll
|
||||||
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
|
||||||
|
|
||||||
|
# The type of a document,
|
||||||
|
# i.e., its classname downcase'd and to_sym'd.
|
||||||
|
#
|
||||||
|
# Returns the type of self.
|
||||||
def type
|
def type
|
||||||
if is_a?(Post)
|
if is_a?(Post)
|
||||||
:post
|
:post
|
||||||
|
@ -124,6 +128,31 @@ module Jekyll
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Determine whether the document is an asset file.
|
||||||
|
# Asset files include CoffeeScript files and Sass/SCSS files.
|
||||||
|
#
|
||||||
|
# Returns true if the extname belongs to the set of extensions
|
||||||
|
# that asset files use.
|
||||||
|
def asset_file?
|
||||||
|
%w[.sass .scss .coffee].include?(ext)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Determine whether the file should be rendered with Liquid.
|
||||||
|
#
|
||||||
|
# Returns false if the document is either an asset file or a yaml file,
|
||||||
|
# true otherwise.
|
||||||
|
def render_with_liquid?
|
||||||
|
!asset_file?
|
||||||
|
end
|
||||||
|
|
||||||
|
# Determine whether the file should be placed into layouts.
|
||||||
|
#
|
||||||
|
# Returns false if the document is either an asset file or a yaml file,
|
||||||
|
# true otherwise.
|
||||||
|
def place_in_layout?
|
||||||
|
!asset_file?
|
||||||
|
end
|
||||||
|
|
||||||
# Recursively render layouts
|
# Recursively render layouts
|
||||||
#
|
#
|
||||||
# layouts - a list of the layouts
|
# layouts - a list of the layouts
|
||||||
|
@ -167,13 +196,13 @@ module Jekyll
|
||||||
payload["highlighter_prefix"] = converter.highlighter_prefix
|
payload["highlighter_prefix"] = converter.highlighter_prefix
|
||||||
payload["highlighter_suffix"] = converter.highlighter_suffix
|
payload["highlighter_suffix"] = converter.highlighter_suffix
|
||||||
|
|
||||||
self.content = render_liquid(content, payload, info)
|
self.content = render_liquid(content, payload, info) if render_with_liquid?
|
||||||
transform
|
transform
|
||||||
|
|
||||||
# output keeps track of what will finally be written
|
# output keeps track of what will finally be written
|
||||||
self.output = content
|
self.output = content
|
||||||
|
|
||||||
render_all_layouts(layouts, payload, info)
|
render_all_layouts(layouts, payload, info) if place_in_layout?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Write the generated page file to the destination directory.
|
# Write the generated page file to the destination directory.
|
||||||
|
|
|
@ -88,6 +88,14 @@ module Jekyll
|
||||||
!(asset_file? || yaml_file?)
|
!(asset_file? || yaml_file?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Determine whether the file should be placed into layouts.
|
||||||
|
#
|
||||||
|
# Returns false if the document is either an asset file or a yaml file,
|
||||||
|
# true otherwise.
|
||||||
|
def place_in_layout?
|
||||||
|
!(asset_file? || yaml_file?)
|
||||||
|
end
|
||||||
|
|
||||||
# The URL template where the document would be accessible.
|
# The URL template where the document would be accessible.
|
||||||
#
|
#
|
||||||
# Returns the URL template for the document.
|
# Returns the URL template for the document.
|
||||||
|
|
|
@ -47,11 +47,15 @@ module Jekyll
|
||||||
output = render_liquid(output, payload, info)
|
output = render_liquid(output, payload, info)
|
||||||
end
|
end
|
||||||
|
|
||||||
place_in_layouts(
|
if document.place_in_layout?
|
||||||
convert(output),
|
place_in_layouts(
|
||||||
payload,
|
convert(output),
|
||||||
info
|
payload,
|
||||||
)
|
info
|
||||||
|
)
|
||||||
|
else
|
||||||
|
convert(output)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Convert the given content using the converters which match this renderer's document.
|
# Convert the given content using the converters which match this renderer's document.
|
||||||
|
|
Loading…
Reference in New Issue