Add support for collections documents to have YAML front matter ending in dots.
This commit is contained in:
parent
848e402937
commit
d7e3d4df8f
|
|
@ -210,7 +210,7 @@ module Jekyll
|
||||||
@data = defaults
|
@data = defaults
|
||||||
end
|
end
|
||||||
@content = File.read(path, merged_file_read_opts(opts))
|
@content = File.read(path, merged_file_read_opts(opts))
|
||||||
if content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
if content =~ /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
|
||||||
@content = $POSTMATCH
|
@content = $POSTMATCH
|
||||||
data_file = SafeYAML.load($1)
|
data_file = SafeYAML.load($1)
|
||||||
unless data_file.nil?
|
unless data_file.nil?
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
title: "YAML with Dots"
|
||||||
|
whatever: foo.bar
|
||||||
|
...
|
||||||
|
|
||||||
|
Use `{{ page.title }}` to build a full configuration for use w/Jekyll.
|
||||||
|
|
||||||
|
Whatever: {{ page.whatever }}
|
||||||
|
|
@ -138,6 +138,7 @@ class TestCollections < Test::Unit::TestCase
|
||||||
_methods/site/generate.md
|
_methods/site/generate.md
|
||||||
_methods/site/initialize.md
|
_methods/site/initialize.md
|
||||||
_methods/um_hi.md
|
_methods/um_hi.md
|
||||||
|
_methods/yaml_with_dots.md
|
||||||
], doc.relative_path
|
], doc.relative_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,26 @@ class TestDocument < Test::Unit::TestCase
|
||||||
}, @document.data)
|
}, @document.data)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with YAML ending in three dots" do
|
||||||
|
|
||||||
|
setup do
|
||||||
|
@site = Site.new(Jekyll.configuration({
|
||||||
|
"collections" => ["methods"],
|
||||||
|
"source" => source_dir,
|
||||||
|
"destination" => dest_dir
|
||||||
|
}))
|
||||||
|
@site.process
|
||||||
|
@document = @site.collections["methods"].docs.last
|
||||||
|
end
|
||||||
|
|
||||||
|
should "know its data" do
|
||||||
|
assert_equal({
|
||||||
|
"title" => "YAML with Dots",
|
||||||
|
"whatever" => "foo.bar"
|
||||||
|
}, @document.data)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
should "output the collection name in the #to_liquid method" do
|
should "output the collection name in the #to_liquid method" do
|
||||||
assert_equal @document.to_liquid['collection'], "methods"
|
assert_equal @document.to_liquid['collection'], "methods"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue