Store#extensionless_path: Change implementation to make overrides easier
This commit is contained in:
parent
0211114ecb
commit
23b6efbb06
|
@ -184,7 +184,17 @@ module Middleman
|
|||
# @return [String]
|
||||
def extensionless_path(file)
|
||||
path = file.dup
|
||||
path = remove_templating_extensions(path)
|
||||
|
||||
# If there is no extension, look for one
|
||||
path = find_extension(path, file) if File.extname(path).empty?
|
||||
path
|
||||
end
|
||||
|
||||
# Removes the templating extensions, while keeping the others
|
||||
# @param [String] path
|
||||
# @return [String]
|
||||
def remove_templating_extensions(path)
|
||||
end_of_the_line = false
|
||||
while !end_of_the_line
|
||||
if !::Tilt[path].nil?
|
||||
|
@ -194,8 +204,13 @@ module Middleman
|
|||
end
|
||||
end
|
||||
|
||||
# If there is no extension, look for one
|
||||
if File.extname(path).empty?
|
||||
path
|
||||
end
|
||||
|
||||
# Finds an extension for path according to file's extension
|
||||
# @param [String] path without extension
|
||||
# @param [String] file path with original extensions
|
||||
def find_extension(path, file)
|
||||
input_ext = File.extname(file)
|
||||
|
||||
if !input_ext.empty?
|
||||
|
@ -204,7 +219,6 @@ module Middleman
|
|||
path << ".#{@app.template_extensions[input_ext]}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
path
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue