Permalink
Browse files

updated convertible to allow for posts with no, or empty YAML

  • Loading branch information...
1 parent b616a4c commit ca98cd01520e4cf225912b5788590ad97c5d4b3a @thinkerbot thinkerbot committed Jun 24, 2009
View
2 lib/jekyll/convertible.rb
@@ -23,6 +23,8 @@ def read_yaml(base, name)
self.data = YAML.load($1)
end
+
+ self.data ||= {}
end
# Transform the contents based on the file extension.
View
2 lib/jekyll/page.rb
@@ -20,8 +20,6 @@ def initialize(site, base, dir, name)
@dir = dir
@name = name
- self.data = {}
-
self.process(name)
self.read_yaml(File.join(base, dir), name)
end
View
3 test/source/_posts/2009-06-22-empty-yaml.textile
@@ -0,0 +1,3 @@
+---
+---
+Empty YAML.
View
1 test/source/_posts/2009-06-22-no-yaml.textile
@@ -0,0 +1 @@
+No YAML.
View
10 test/test_post.rb
@@ -235,6 +235,16 @@ def do_render(post)
assert post.tags.include?('cooking')
assert post.tags.include?('pizza')
end
+
+ should "allow no yaml" do
+ post = setup_post("2009-06-22-no-yaml.textile")
+ assert_equal "No YAML.", post.content
+ end
+
+ should "allow empty yaml" do
+ post = setup_post("2009-06-22-empty-yaml.textile")
+ assert_equal "Empty YAML.", post.content
+ end
context "rendering" do
setup do

0 comments on commit ca98cd0

Please sign in to comment.