Remove template lookup cache in build mode. Fixes #1301

This commit is contained in:
Thomas Reynolds 2014-07-20 13:37:16 -07:00
parent 22dace72df
commit debf3c704b

View file

@ -161,11 +161,23 @@ module Middleman
# @param [String] request_path
# @option options [Boolean] :preferred_engine If set, try this engine first, then fall back to any engine.
# @return [String, Boolean] Either the path to the template, or false
Contract IsA['Middleman::Application'], Or[Symbol, String], Hash => Maybe[String]
Contract IsA['Middleman::Application'], Or[Symbol, String], Maybe[Hash] => Maybe[String]
def self.resolve_template(app, request_path, options={})
# Find the path by searching or using the cache
request_path = request_path.to_s
# Cache lookups in build mode only
if app.build?
cache.fetch(:resolve_template, request_path, options) do
uncached_resolve_template(app, request_path, options)
end
else
uncached_resolve_template(app, request_path, options)
end
end
Contract IsA['Middleman::Application'], String, Hash => Maybe[String]
def self.uncached_resolve_template(app, request_path, options)
relative_path = Util.strip_leading_slash(request_path)
on_disk_path = File.expand_path(relative_path, app.source_dir)
@ -217,5 +229,4 @@ module Middleman
end
end
end
end
end