Added support for underscore imports.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import os
|
||||
from itertools import product
|
||||
|
||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||
from django.conf import settings
|
||||
@@ -70,9 +71,12 @@ class DjangoScss(Scss):
|
||||
|
||||
dirname, filename = os.path.split(path)
|
||||
name, ext = os.path.splitext(filename)
|
||||
if not ext:
|
||||
for extension in self.supported_extensions:
|
||||
paths.append(os.path.join(dirname, name + extension))
|
||||
if ext:
|
||||
search_exts = [ext]
|
||||
else:
|
||||
search_exts = self.supported_extensions
|
||||
for prefix, suffix in product(('_', ''), search_exts):
|
||||
paths.append(os.path.join(dirname, prefix + name + suffix))
|
||||
return paths
|
||||
|
||||
def _find_source_file(self, filename, relative_to=None):
|
||||
|
||||
3
testproject/testproject/static/css/_baz.scss
Normal file
3
testproject/testproject/static/css/_baz.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
.baz {
|
||||
color: #123456;
|
||||
}
|
||||
@@ -26,6 +26,9 @@ SASS_CONTENTS = """
|
||||
with open(os.path.join(settings.BASE_DIR, 'testproject', 'static', 'css', 'css_file.css')) as f:
|
||||
CSS_CONTENTS = f.read()
|
||||
|
||||
with open(os.path.join(settings.BASE_DIR, 'testproject', 'static', 'css', '_baz.scss')) as f:
|
||||
BAZ_CONTENTS = f.read()
|
||||
|
||||
|
||||
class CompilerTestMixin(object):
|
||||
def setUp(self):
|
||||
@@ -77,6 +80,10 @@ class ImportTestMixin(CompilerTestMixin):
|
||||
actual = self.compiler.compile(scss_string='@import "/css/css_file";')
|
||||
self.assertEqual(clean_css(actual), clean_css(CSS_CONTENTS))
|
||||
|
||||
def test_import_underscore_file(self):
|
||||
actual = self.compiler.compile(scss_string='@import "/css/baz";')
|
||||
self.assertEqual(clean_css(actual), clean_css(BAZ_CONTENTS))
|
||||
|
||||
|
||||
@override_settings(DEBUG=True)
|
||||
class FindersImportTest(ImportTestMixin, TestCase):
|
||||
|
||||
Reference in New Issue
Block a user