diff --git a/doc-src/INDENTED_SYNTAX.md b/doc-src/INDENTED_SYNTAX.md index a2a5d64c..fbe28e2a 100644 --- a/doc-src/INDENTED_SYNTAX.md +++ b/doc-src/INDENTED_SYNTAX.md @@ -121,10 +121,7 @@ is compiled to: ### `@import` -The `@import` directive in Sass does not require quotes. -Quotes may be used; -if they are, the directive will always be interpreted -as a plain CSS `@import` rule. +The `@import` directive in Sass does not require quotes, although they may be used. For example, this SCSS: @import "themes/dark"; diff --git a/doc-src/SASS_CHANGELOG.md b/doc-src/SASS_CHANGELOG.md index 03c93d6e..9189dcd8 100644 --- a/doc-src/SASS_CHANGELOG.md +++ b/doc-src/SASS_CHANGELOG.md @@ -45,6 +45,12 @@ this won't cause any backwards-incompatibilities. * `#{}` interpolation within strings will now be converted properly to `#{}` interpolation within strings. +### `@import` in Sass + +The Sass `@import` statement now allows non-CSS files to be specified with quotes, +for similarity with the SCSS syntax. For example, `@import "foo.sass"` +Will now import the `foo.sass` file, rather than compiling to `@import "foo.sass";`. + ### CSS Parsing The proprietary Microsoft `alpha(opacity=20)` syntax is now correctly parsed. diff --git a/lib/sass/engine.rb b/lib/sass/engine.rb index 14f9da4a..5403ca77 100644 --- a/lib/sass/engine.rb +++ b/lib/sass/engine.rb @@ -461,10 +461,13 @@ WARNING # If value begins with url( or ", # it's a CSS @import rule and we don't want to touch it. - if directive == "import" && value !~ /^(url\(|")/ + if directive == "import" && value !~ /^(url\(|["'])/ raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath import directives.", :line => @line + 1) unless line.children.empty? - value.split(/,\s*/).map {|f| Tree::ImportNode.new(f)} + value.split(/,\s*/).map do |f| + f = $1 || $2 || $3 if f =~ Sass::SCSS::RX::STRING || f =~ Sass::SCSS::RX::URI + Tree::ImportNode.new(f) + end elsif directive == "mixin" parse_mixin_definition(line) elsif directive == "include" diff --git a/test/sass/templates/import.sass b/test/sass/templates/import.sass index 032ef94a..e502cc7b 100644 --- a/test/sass/templates/import.sass +++ b/test/sass/templates/import.sass @@ -3,7 +3,7 @@ $preconst: hello =premixin pre-mixin: here -@import importee.sass, scss_importee, basic.sass, basic.css, ../results/complex.css, partial.sass +@import importee.sass, scss_importee, "basic.sass", basic.css, ../results/complex.css, url(partial.sass) nonimported :myconst $preconst