fix double-run layout lookup
This commit is contained in:
parent
fee6fba15d
commit
2b545f8e35
|
@ -120,6 +120,9 @@ module Middleman::Sitemap
|
||||||
end
|
end
|
||||||
|
|
||||||
def locate_layout(name, preferred_engine=nil)
|
def locate_layout(name, preferred_engine=nil)
|
||||||
|
layout_path = false
|
||||||
|
|
||||||
|
if !preferred_engine.nil?
|
||||||
# Check root
|
# Check root
|
||||||
layout_path, *etc = resolve_template(name, :preferred_engine => preferred_engine)
|
layout_path, *etc = resolve_template(name, :preferred_engine => preferred_engine)
|
||||||
|
|
||||||
|
@ -127,9 +130,12 @@ module Middleman::Sitemap
|
||||||
if !layout_path
|
if !layout_path
|
||||||
layout_path, *etc = resolve_template(File.join("layouts", name.to_s), :preferred_engine => preferred_engine)
|
layout_path, *etc = resolve_template(File.join("layouts", name.to_s), :preferred_engine => preferred_engine)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Check root, no preference
|
# Check root, no preference
|
||||||
|
if !layout_path
|
||||||
layout_path, *etc = resolve_template(name)
|
layout_path, *etc = resolve_template(name)
|
||||||
|
end
|
||||||
|
|
||||||
# Check layouts folder, no preference
|
# Check layouts folder, no preference
|
||||||
if !layout_path
|
if !layout_path
|
||||||
|
@ -145,7 +151,9 @@ module Middleman::Sitemap
|
||||||
relative_path = request_path.sub(%r{^/}, "")
|
relative_path = request_path.sub(%r{^/}, "")
|
||||||
on_disk_path = File.expand_path(relative_path, app.source_dir)
|
on_disk_path = File.expand_path(relative_path, app.source_dir)
|
||||||
|
|
||||||
preferred_engine = if options.has_key?(:preferred_engine)
|
preferred_engine = "*"
|
||||||
|
|
||||||
|
if options.has_key?(:preferred_engine)
|
||||||
extension_class = ::Tilt[options[:preferred_engine]]
|
extension_class = ::Tilt[options[:preferred_engine]]
|
||||||
matched_exts = []
|
matched_exts = []
|
||||||
|
|
||||||
|
@ -155,25 +163,24 @@ module Middleman::Sitemap
|
||||||
matched_exts << ext
|
matched_exts << ext
|
||||||
end
|
end
|
||||||
|
|
||||||
"{" + matched_exts.join(",") + "}"
|
if matched_exts.length > 0
|
||||||
|
preferred_engine = "{" + matched_exts.join(",") + "}"
|
||||||
else
|
else
|
||||||
"*"
|
return false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
path_with_ext = on_disk_path + "." + preferred_engine
|
path_with_ext = on_disk_path + "." + preferred_engine
|
||||||
|
|
||||||
found_path = Dir[path_with_ext].find do |path|
|
found_path = Dir[path_with_ext].find do |path|
|
||||||
::Tilt[path]
|
::Tilt[path]
|
||||||
end
|
end
|
||||||
|
|
||||||
result = if found_path || File.exists?(on_disk_path)
|
if found_path || File.exists?(on_disk_path)
|
||||||
engine = found_path ? File.extname(found_path)[1..-1].to_sym : nil
|
engine = found_path ? File.extname(found_path)[1..-1].to_sym : nil
|
||||||
[ found_path || on_disk_path, engine ]
|
[ found_path || on_disk_path, engine ]
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
result
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue