Skip to content

Commit

Permalink
[Sass] Deprecate '@import foo' translating to '@import foo.css;'.
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Jan 3, 2010
1 parent 1de86d2 commit cb63e07
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
8 changes: 8 additions & 0 deletions doc-src/SASS_CHANGELOG.md
Expand Up @@ -16,6 +16,14 @@

* Report the filename in warnings about selectors without properties.

### Must Read!

* When `@import` is given a filename without an extension,
the behavior of rendering a CSS `@import` if no Sass file is found
is deprecated.
In future versions, `@import foo` will either import the template
or raise an error.

## [2.2.16](http://github.com/nex3/haml/commit/2.2.16)

* Fixed a bug where modules containing user-defined Sass functions
Expand Down
14 changes: 5 additions & 9 deletions doc-src/SASS_REFERENCE.md
Expand Up @@ -449,13 +449,16 @@ using the [`:load_paths`](#load_paths-option) option.

`@import` takes a filename with or without an extension.
If an extension isn't provided,
Sass will try to find a Sass file with the given basename in the load paths,
and, failing that, will assume a relevant CSS file will be available.
Sass will try to find a Sass file with the given basename in the load paths.

For example,

@import foo.sass

or

@import foo

would compile to

.foo {
Expand All @@ -469,13 +472,6 @@ would compile to

@import foo.css;

Finally,

@import foo

might compile to either,
depending on whether or not a file called "foo.sass" existed.

#### Partials {#partials}

If you have a Sass file that you want to import
Expand Down
9 changes: 8 additions & 1 deletion lib/sass/files.rb
Expand Up @@ -77,7 +77,14 @@ def find_file_to_import(filename, load_paths)
new_filename = find_full_path("#{filename}.sass", load_paths)

return new_filename if new_filename
return filename + '.css' unless was_sass
unless was_sass
warn <<END
WARNING: #{filename}.sass not found. Using #{filename}.css instead.
This behavior is deprecated and will be removed in a future version.
If you really need #{filename}.css, import it explicitly.
END
return filename + '.css'
end
raise SyntaxError.new("File to import not found or unreadable: #{original_filename}.", @line)
end

Expand Down
10 changes: 10 additions & 0 deletions test/sass/engine_test.rb
Expand Up @@ -211,6 +211,16 @@ def test_sass_import
assert File.exists?(sassc_path("importee"))
end

def test_nonexistent_extensionless_import
assert_warning(<<WARN) do
WARNING: nonexistent.sass not found. Using nonexistent.css instead.
This behavior is deprecated and will be removed in a future version.
If you really need nonexistent.css, import it explicitly.
WARN
assert_equal("@import url(nonexistent.css);\n", render("@import nonexistent"))
end
end

def test_no_cache
assert !File.exists?(sassc_path("importee"))
renders_correctly("import", {
Expand Down

0 comments on commit cb63e07

Please sign in to comment.