From 424fee0722bb580a7ea2d8fa908a6cd745370f9b Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Thu, 23 May 2013 13:31:38 -0700 Subject: [PATCH] Cache frontmatter repeated calling of recursively_enhance --- .../lib/middleman-core/core_extensions/front_matter.rb | 9 ++++++--- .../lib/middleman-more/extensions/directory_indexes.rb | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) 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 d6a53ee4..226bebcd 100644 --- a/middleman-core/lib/middleman-core/core_extensions/front_matter.rb +++ b/middleman-core/lib/middleman-core/core_extensions/front_matter.rb @@ -181,7 +181,7 @@ module Middleman::CoreExtensions module ResourceInstanceMethods def ignored? - if !proxy? && data["ignored"] == true + if !proxy? && raw_data[:ignored] == true true else super @@ -199,13 +199,16 @@ module Middleman::CoreExtensions # This page's frontmatter # @return [Hash] def data - ::Middleman::Util.recursively_enhance(raw_data).freeze + @enhanced_data ||= {} + @enhanced_data[raw_data] ||= begin + ::Middleman::Util.recursively_enhance(raw_data).freeze + end end # Override Resource#content_type to take into account frontmatter def content_type # Allow setting content type in frontmatter too - fm_type = data[:content_type] + fm_type = raw_data[:content_type] return fm_type if fm_type super diff --git a/middleman-core/lib/middleman-more/extensions/directory_indexes.rb b/middleman-core/lib/middleman-more/extensions/directory_indexes.rb index a082abeb..18818f5e 100644 --- a/middleman-core/lib/middleman-more/extensions/directory_indexes.rb +++ b/middleman-core/lib/middleman-more/extensions/directory_indexes.rb @@ -13,7 +13,7 @@ class Middleman::Extensions::DirectoryIndexes < ::Middleman::Extension File.extname(index_file) != resource.ext # Check if frontmatter turns directory_index off - next if resource.data[:directory_index] == false + next if resource.raw_data[:directory_index] == false # Check if file metadata (options set by "page" in config.rb) turns directory_index off next if resource.metadata[:options][:directory_index] == false