lib/lookbook/page.rb in lookbook-0.7.1 vs lib/lookbook/page.rb in lookbook-0.7.2.beta.0

- old
+ new

@@ -13,13 +13,16 @@ :header, :footer, :data ] + attr_reader :errors + def initialize(path, base_path) @pathname = Pathname.new path @base_path = base_path + @errors = [] end def path rel_path = @pathname.relative_path_from(@base_path) (rel_path.dirname.to_s == "." ? name : "#{rel_path.dirname}/#{name}") @@ -95,10 +98,19 @@ File.read(full_path) end def options return @options if @options - frontmatter = (get_frontmatter(file_contents) || {}).deep_symbolize_keys + begin + frontmatter = (get_frontmatter(file_contents) || {}).deep_symbolize_keys + rescue => exception + frontmatter = {} + @errors.push(Lookbook::Error.new(exception, { + title: "YAML frontmatter parsing error", + file_name: @pathname.to_s, + line_number: nil + })) + end options = Lookbook.config.page_options.deep_merge(frontmatter).with_indifferent_access options[:id] = options[:id] ? generate_id(options[:id]) : generate_id(lookup_path) options[:label] ||= name.titleize options[:title] ||= options[:label] options[:hidden] ||= false