From 85f06ccecdde2a55e1fc807b7ae2d558929dd291 Mon Sep 17 00:00:00 2001 From: Casey Leask Date: Mon, 3 Dec 2012 11:15:36 +1100 Subject: [PATCH] Added fix for empty YAML --- middleman-core/features/front-matter.feature | 13 ++++++++++++- .../middleman-core/core_extensions/front_matter.rb | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/middleman-core/features/front-matter.feature b/middleman-core/features/front-matter.feature index 5e57de30..b8d326c5 100644 --- a/middleman-core/features/front-matter.feature +++ b/middleman-core/features/front-matter.feature @@ -69,4 +69,15 @@ Feature: YAML Front Matter <%= data.page.title %> """ When I go to "/front-matter-change.html" - Then I should see "Hola Mundo" \ No newline at end of file + Then I should see "Hola Mundo" + + Scenario: A template should handle an empty YAML feed + Given the Server is running at "frontmatter-app" + And the file "source/front-matter-change.html.erb" has the contents + """ + --- + --- + Hello World + """ + When I go to "/front-matter-change.html" + Then I should see "Hello World" diff --git a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb index f021dde8..baa7467f 100644 --- a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb +++ b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb @@ -31,7 +31,7 @@ module Middleman::CoreExtensions ) sitemap.provides_metadata do |path| - fmdata = frontmatter_manager.data(path).first + fmdata = frontmatter_manager.data(path).first || {} data = {} %w(layout layout_engine).each do |opt| @@ -158,7 +158,7 @@ module Middleman::CoreExtensions # @return [void] def manipulate_resource_list(resources) resources.each do |r| - if !r.proxy? && r.data["ignored"] == true + if !r.proxy? && !r.data.nil? && r.data["ignored"] == true r.frontmatter_ignored = true end end