Skip to content

Commit dae35e3

Browse files
committed
Merge branch 'jor123-output-styles'
2 parents cf859d8 + 7954487 commit dae35e3

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

CHANGELOG.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changelog
44
0.3 (xx.xx.20xx)
55
~~~~~~~~~~~~~~~~
66
* Enabled source comments when DEBUG is True; can be overridden with the LIBSASS_SOURCE_COMMENTS setting
7+
* Added LIBSASS_OUTPUT_STYLE setting
78

89
0.2 (22.05.2014)
910
~~~~~~~~~~~~~~~~

README.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ possible to import files across different apps::
3838
@import "myotherapp/css/widget.scss"
3939

4040

41-
Source comments
42-
~~~~~~~~~~~~~~~
41+
Settings
42+
~~~~~~~~
4343

44-
SASS source comments (adds comments about source lines) are enabled when Django's DEBUG is
45-
enabled. This setting can be overridden with a LIBSASS_SOURCE_COMMENTS boolean setting.
44+
The following settings can be used to control django-libsass's behaviour:
45+
46+
* ``LIBSASS_SOURCE_COMMENTS`` - whether to enable SASS source comments (adds comments about source lines). Defaults to ``True`` when Django's ``DEBUG`` is ``True``, ``False`` otherwise.
47+
* ``LIBSASS_OUTPUT_STYLE`` - SASS output style. Options are ``'nested'``, ``'expanded'``, ``'compact'`` and ``'compressed'``, although as of libsass 3.0.2 only ``'nested'`` and ``'compressed'`` are implemented. Default is 'nested'. See `SASS documentation for output styles <http://sass-lang.com/documentation/file.SASS_REFERENCE.html#output_style>`_. Note that `django-compressor's settings <http://django-compressor.readthedocs.org/en/latest/settings/>`_ may also affect the formatting of the resulting CSS.
4648

4749

4850
Why django-libsass?

django_libsass.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import sass
55
from compressor.filters.base import FilterBase
66

7+
OUTPUT_STYLE = getattr(settings, 'LIBSASS_OUTPUT_STYLE', 'nested')
78
SOURCE_COMMENTS = getattr(settings, 'LIBSASS_SOURCE_COMMENTS', settings.DEBUG)
89

910

@@ -52,6 +53,10 @@ def __init__(self, content, attrs=None, filter_type=None, charset=None, filename
5253

5354
def input(self, **kwargs):
5455
if self.filename:
55-
return compile(filename=self.filename, source_comments=SOURCE_COMMENTS)
56+
return compile(filename=self.filename,
57+
output_style=OUTPUT_STYLE,
58+
source_comments=SOURCE_COMMENTS)
5659
else:
57-
return compile(string=self.content)
60+
return compile(string=self.content,
61+
output_style=OUTPUT_STYLE)
62+

0 commit comments

Comments
 (0)