mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Sass] Fix an old merge error.
This commit is contained in:
parent
df8aaaa48e
commit
e078110853
3 changed files with 28 additions and 67 deletions
|
@ -991,7 +991,7 @@ require 'haml/version'
|
|||
# or `width = !main_width`.
|
||||
# By default, either syntax is valid.
|
||||
#
|
||||
# `cache`
|
||||
# {#cache} `cache`
|
||||
# : Whether parsed Sass files should be cached,
|
||||
# allowing greater speed. Defaults to true.
|
||||
#
|
||||
|
|
|
@ -468,71 +468,5 @@ END
|
|||
Tree::FileNode.new(filename)
|
||||
end.flatten
|
||||
end
|
||||
<<<<<<< HEAD:lib/sass/engine.rb
|
||||
=======
|
||||
|
||||
# Find the full filename of a Sass or CSS file to import.
|
||||
# This follows Sass's import rules:
|
||||
# if the filename given ends in `".sass"` or `".css"`,
|
||||
# it will try to find that type of file;
|
||||
# otherwise, it will try to find the corresponding Sass file
|
||||
# and fall back on CSS if it's not available.
|
||||
#
|
||||
# Any Sass filename returned will correspond to
|
||||
# an actual Sass file on the filesystem.
|
||||
# CSS filenames, however, may not;
|
||||
# they're expected to be put through directly to the stylesheet
|
||||
# as CSS `@import` statements.
|
||||
#
|
||||
# @param filename [String] The filename to search for
|
||||
# @param load_paths [Array<String>] The set of filesystem paths
|
||||
# to search for Sass files.
|
||||
# @return [String] The filename of the imported file.
|
||||
# This is an absolute path if the file is a `".sass"` file.
|
||||
# @raise [Sass::SyntaxError] if `filename` ends in ``".sass"``
|
||||
# and no corresponding Sass file could be found.
|
||||
def self.find_file_to_import(filename, load_paths)
|
||||
was_sass = false
|
||||
original_filename = filename
|
||||
|
||||
if filename[-5..-1] == ".sass"
|
||||
filename = filename[0...-5]
|
||||
was_sass = true
|
||||
elsif filename[-4..-1] == ".css"
|
||||
return filename
|
||||
end
|
||||
|
||||
new_filename = find_full_path("#{filename}.sass", load_paths)
|
||||
|
||||
return new_filename if new_filename
|
||||
return filename + '.css' unless was_sass
|
||||
raise SyntaxError.new("File to import not found or unreadable: #{original_filename}.", @line)
|
||||
end
|
||||
|
||||
# Checks each of the paths in `load_paths` for a file named `filename`.
|
||||
#
|
||||
# This will also find files with the same name as `filename`
|
||||
# but with an underscore prefixing the basename.
|
||||
# For example, if filename is `"foo/bar/baz.sass"`,
|
||||
# this will look for `"foo/bar/baz.sass"` **and** `"foo/bar/_baz.sass"`.
|
||||
#
|
||||
# @param filename [String] The filename to search for
|
||||
# @param load_paths [Array<String>] The set of filesystem paths
|
||||
# to search for Sass files
|
||||
# @return [String] The absolute path of the matching file,
|
||||
# or nil if no matching file is found
|
||||
def self.find_full_path(filename, load_paths)
|
||||
segments = filename.split(File::SEPARATOR)
|
||||
segments.push "_#{segments.pop}"
|
||||
partial_name = segments.join(File::SEPARATOR)
|
||||
load_paths.each do |path|
|
||||
[partial_name, filename].each do |name|
|
||||
full_path = File.join(path, name)
|
||||
return full_path if File.readable?(full_path)
|
||||
end
|
||||
end
|
||||
nil
|
||||
end
|
||||
>>>>>>> yard:lib/sass/engine.rb
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,13 @@ module Sass
|
|||
module Files
|
||||
extend self
|
||||
|
||||
# Returns the {Sass::Tree} for the given file,
|
||||
# reading it from the Sass cache if possible.
|
||||
#
|
||||
# @param filename [String] The path to the Sass file
|
||||
# @param options [Hash<Symbol, Object>] The options hash.
|
||||
# Only the [`:cache_location`](../Sass.html#cache) option is used
|
||||
# @raise [Sass::SyntaxError] if there's an error in the document
|
||||
def tree_for(filename, options)
|
||||
options = Sass::Engine::DEFAULT_OPTIONS.merge(options)
|
||||
text = File.read(filename)
|
||||
|
@ -33,6 +40,26 @@ module Sass
|
|||
root
|
||||
end
|
||||
|
||||
# Find the full filename of a Sass or CSS file to import.
|
||||
# This follows Sass's import rules:
|
||||
# if the filename given ends in `".sass"` or `".css"`,
|
||||
# it will try to find that type of file;
|
||||
# otherwise, it will try to find the corresponding Sass file
|
||||
# and fall back on CSS if it's not available.
|
||||
#
|
||||
# Any Sass filename returned will correspond to
|
||||
# an actual Sass file on the filesystem.
|
||||
# CSS filenames, however, may not;
|
||||
# they're expected to be put through directly to the stylesheet
|
||||
# as CSS `@import` statements.
|
||||
#
|
||||
# @param filename [String] The filename to search for
|
||||
# @param load_paths [Array<String>] The set of filesystem paths
|
||||
# to search for Sass files.
|
||||
# @return [String] The filename of the imported file.
|
||||
# This is an absolute path if the file is a `".sass"` file.
|
||||
# @raise [Sass::SyntaxError] if `filename` ends in ``".sass"``
|
||||
# and no corresponding Sass file could be found.
|
||||
def find_file_to_import(filename, load_paths)
|
||||
was_sass = false
|
||||
original_filename = filename
|
||||
|
|
Loading…
Add table
Reference in a new issue