1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00

Cache frontmatter repeated calling of recursively_enhance

This commit is contained in:
Thomas Reynolds 2013-05-23 13:31:38 -07:00
parent dbbf84016f
commit 424fee0722
2 changed files with 7 additions and 4 deletions

View file

@ -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

View file

@ -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