Fix loading data from subdir with a period in name #5429

This commit is contained in:
Anatoliy Yastreb 2016-10-01 13:09:50 +01:00
parent aa901cdaba
commit cff8f2994c
3 changed files with 23 additions and 2 deletions

View File

@ -37,10 +37,10 @@ module Jekyll
path = @site.in_source_dir(dir, entry)
next if @entry_filter.symlink?(path)
key = sanitize_filename(File.basename(entry, ".*"))
if File.directory?(path)
read_data_to(path, data[key] = {})
read_data_to(path, data[entry] = {})
else
key = sanitize_filename(File.basename(entry, ".*"))
data[key] = read_data_file(path)
end
end

View File

@ -0,0 +1,6 @@
name: Dairy
products:
- name: cheese
price: 5.5
- name: milk
price: 2.75

View File

@ -438,6 +438,21 @@ class TestSite < JekyllUnitTest
)
end
should "auto load yaml files in subdirectory with a period in the name" do
site = Site.new(site_configuration)
site.process
file_content = SafeYAML.load_file(File.join(
source_dir, "_data", "categories.01", "dairy.yaml"
))
assert_equal site.data["categories.01"]["dairy"], file_content
assert_equal(
site.site_payload["site"]["data"]["categories.01"]["dairy"],
file_content
)
end
should "load symlink files in unsafe mode" do
site = Site.new(site_configuration("safe" => false))
site.process