summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEevee (Alex Munroe) <eevee.git@veekun.com>2014-11-12 15:57:34 -0800
committerEevee (Alex Munroe) <eevee.git@veekun.com>2014-11-12 15:57:34 -0800
commit018400aadd8fb770e7dd2293480147399fc58ed1 (patch)
tree3f69e10a095a0c337c4b13fff15a48f4ed489cc8
parent86712d21fe7c3abdd7e593973fb35010422f1a41 (diff)
downloadpyscss-018400aadd8fb770e7dd2293480147399fc58ed1.tar.gz
Undocumented support for allowing @import to work on .css files.
Mostly for the benefit of django-pyscss (which thusfar has explicitly forced this behavior) so it doesn't need to copy and paste large blocks of fiddly code, but seems like a popular feature request in Ruby Sass as well.
-rw-r--r--scss/compiler.py10
-rw-r--r--scss/extension/core.py2
-rw-r--r--scss/legacy.py3
3 files changed, 12 insertions, 3 deletions
diff --git a/scss/compiler.py b/scss/compiler.py
index 96d54ec..82c5390 100644
--- a/scss/compiler.py
+++ b/scss/compiler.py
@@ -86,6 +86,7 @@ class Compiler(object):
def __init__(
self, root=Path(), search_path=(),
namespace=None, extensions=(CoreExtension,),
+ import_static_css=False,
output_style='nested', generate_source_map=False,
live_errors=False, warn_unused_imports=False,
ignore_parse_errors=False,
@@ -137,6 +138,13 @@ class Compiler(object):
.format(extension)
)
+ if import_static_css:
+ self.dynamic_extensions = ('.scss', '.sass', '.css')
+ self.static_extensions = ()
+ else:
+ self.dynamic_extensions = ('.scss', '.sass')
+ self.static_extensions = ('.css',)
+
self.output_style = output_style
self.generate_source_map = generate_source_map
self.live_errors = live_errors
@@ -827,7 +835,7 @@ class Compilation(object):
# If the filename begins with an http protocol
sass_path.value.startswith(('http://', 'https://')) or
# If the filename ends with .css
- sass_path.value.endswith('.css')):
+ sass_path.value.endswith(self.compiler.static_extensions)):
css_imports.append(sass_path.render(compress=False))
continue
diff --git a/scss/extension/core.py b/scss/extension/core.py
index d3cf164..227b559 100644
--- a/scss/extension/core.py
+++ b/scss/extension/core.py
@@ -41,7 +41,7 @@ class CoreExtension(Extension):
if path.suffix:
search_exts = [path.suffix]
else:
- search_exts = ['.scss', '.sass']
+ search_exts = compilation.compiler.dynamic_extensions
relative_to = path.parent
basename = path.stem
diff --git a/scss/legacy.py b/scss/legacy.py
index 1e69e65..b155330 100644
--- a/scss/legacy.py
+++ b/scss/legacy.py
@@ -83,7 +83,7 @@ class Scss(object):
def compile(
self, scss_string=None, scss_file=None, source_files=None,
super_selector=None, filename=None, is_sass=None,
- line_numbers=True):
+ line_numbers=True, import_static_css=False):
"""Compile Sass to CSS. Returns a single CSS string.
This method is DEPRECATED; see :mod:`scss.compiler` instead.
@@ -140,6 +140,7 @@ class Scss(object):
BootstrapExtension,
],
search_path=fixed_search_path,
+ import_static_css=import_static_css,
live_errors=self.live_errors,
generate_source_map=self._scss_opts.get('debug_info', False),
output_style=output_style,