Only read layouts from source_dir or theme_dir (#6788)
Merge pull request 6788
This commit is contained in:
parent
41b8192b07
commit
bfc733da90
|
@ -23,7 +23,7 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
def layout_directory
|
def layout_directory
|
||||||
@layout_directory ||= (layout_directory_in_cwd || layout_directory_inside_source)
|
@layout_directory ||= site.in_source_dir(site.config["layouts_dir"])
|
||||||
end
|
end
|
||||||
|
|
||||||
def theme_layout_directory
|
def theme_layout_directory
|
||||||
|
@ -57,14 +57,5 @@ module Jekyll
|
||||||
|
|
||||||
Dir.chdir(directory) { yield }
|
Dir.chdir(directory) { yield }
|
||||||
end
|
end
|
||||||
|
|
||||||
def layout_directory_inside_source
|
|
||||||
site.in_source_dir(site.config["layouts_dir"])
|
|
||||||
end
|
|
||||||
|
|
||||||
def layout_directory_in_cwd
|
|
||||||
dir = Jekyll.sanitized_path(Dir.pwd, site.config["layouts_dir"])
|
|
||||||
dir if File.directory?(dir) && !site.safe
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,8 +27,9 @@ class TestLayoutReader < JekyllUnitTest
|
||||||
allow(Dir).to receive(:pwd).and_return(source_dir("blah"))
|
allow(Dir).to receive(:pwd).and_return(source_dir("blah"))
|
||||||
end
|
end
|
||||||
|
|
||||||
should "know to use the layout directory relative to CWD" do
|
should "ignore the layout directory in CWD and use the directory relative to site source" do
|
||||||
assert_equal LayoutReader.new(@site).layout_directory, source_dir("blah/_layouts")
|
refute_equal source_dir("blah/_layouts"), LayoutReader.new(@site).layout_directory
|
||||||
|
assert_equal source_dir("_layouts"), LayoutReader.new(@site).layout_directory
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue