Skip to content

Commit 91d4e12

Browse files
committed
Merge pull request #27 from item4/bugfix/support-partial
Bugfix/support partial
2 parents 4f40fed + 09c721a commit 91d4e12

File tree

6 files changed

+27
-1
lines changed

6 files changed

+27
-1
lines changed

docs/changes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Version 0.5.2
66

77
To be released.
88

9+
- Added missing `partial import`_ support. [:issue:`27` by item4]
10+
11+
.. _partial import: http://sass-lang.com/documentation/file.SASS_REFERENCE.html#partials
12+
913

1014
Version 0.5.1
1115
-------------

sasstests.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@
6666
font: '나눔고딕', sans-serif; }
6767
'''
6868

69+
E_EXPECTED_CSS = '''\
70+
a {
71+
color: red; }
72+
'''
73+
6974
SUBDIR_RECUR_EXPECTED_CSS = '''\
7075
body p {
7176
color: blue; }
@@ -187,6 +192,8 @@ def test_compile_filename(self):
187192
self.assertEqual(D_EXPECTED_CSS, actual)
188193
else:
189194
self.assertEqual(D_EXPECTED_CSS.decode('utf-8'), actual)
195+
actual = sass.compile(filename='test/e.scss')
196+
assert actual == E_EXPECTED_CSS
190197
self.assertRaises(IOError, sass.compile,
191198
filename='test/not-exist.sass')
192199
self.assertRaises(TypeError, sass.compile, filename=1234)
@@ -234,7 +241,7 @@ def test_builder_build_directory(self):
234241
css_path = os.path.join(temp_path, 'css')
235242
shutil.copytree('test', sass_path)
236243
result_files = build_directory(sass_path, css_path)
237-
assert len(result_files) == 5
244+
assert len(result_files) == 6
238245
assert result_files['a.scss'] == 'a.scss.css'
239246
with open(os.path.join(css_path, 'a.scss.css'), **utf8_if_py3) as f:
240247
css = f.read()
@@ -251,6 +258,10 @@ def test_builder_build_directory(self):
251258
with open(os.path.join(css_path, 'd.scss.css'), **utf8_if_py3) as f:
252259
css = f.read()
253260
self.assertEqual(D_EXPECTED_CSS, css)
261+
assert result_files['e.scss'] == 'e.scss.css'
262+
with open(os.path.join(css_path, 'e.scss.css'), **utf8_if_py3) as f:
263+
css = f.read()
264+
assert css == E_EXPECTED_CSS
254265
assert (result_files[os.path.join('subdir', 'recur.scss')] ==
255266
os.path.join('subdir', 'recur.scss.css'))
256267
with open(os.path.join(css_path, 'subdir', 'recur.scss.css'),

sassutils/builder.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ def build_directory(sass_path, css_path, _root_sass=None, _root_css=None):
4646
for name in os.listdir(sass_path):
4747
sass_fullname = os.path.join(sass_path, name)
4848
if SUFFIX_PATTERN.search(name) and os.path.isfile(sass_fullname):
49+
if name[0] == '_':
50+
# Do not compile if it's partial
51+
continue
4952
css_fullname = os.path.join(css_path, name) + '.css'
5053
css = compile(filename=sass_fullname, include_paths=[_root_sass])
5154
with io.open(css_fullname, 'w', encoding='utf-8') as css_file:

test/_f.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$test-variable : true !default;

test/e.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@import "f";
2+
@import "subdir/sub";

test/subdir/_sub.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@if $test-variable == true {
2+
a {
3+
color: red;
4+
}
5+
}

0 commit comments

Comments
 (0)