Skip to content

Commit

Permalink
Merge branch 'jor123-output-styles'
Browse files Browse the repository at this point in the history
  • Loading branch information
gasman committed Dec 16, 2014
2 parents cf859d8 + 7954487 commit dae35e3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
0.3 (xx.xx.20xx)
~~~~~~~~~~~~~~~~
* Enabled source comments when DEBUG is True; can be overridden with the LIBSASS_SOURCE_COMMENTS setting
* Added LIBSASS_OUTPUT_STYLE setting

0.2 (22.05.2014)
~~~~~~~~~~~~~~~~
Expand Down
10 changes: 6 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ possible to import files across different apps::
@import "myotherapp/css/widget.scss"


Source comments
~~~~~~~~~~~~~~~
Settings
~~~~~~~~

SASS source comments (adds comments about source lines) are enabled when Django's DEBUG is
enabled. This setting can be overridden with a LIBSASS_SOURCE_COMMENTS boolean setting.
The following settings can be used to control django-libsass's behaviour:

* ``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.
* ``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.


Why django-libsass?
Expand Down
9 changes: 7 additions & 2 deletions django_libsass.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sass
from compressor.filters.base import FilterBase

OUTPUT_STYLE = getattr(settings, 'LIBSASS_OUTPUT_STYLE', 'nested')
SOURCE_COMMENTS = getattr(settings, 'LIBSASS_SOURCE_COMMENTS', settings.DEBUG)


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

def input(self, **kwargs):
if self.filename:
return compile(filename=self.filename, source_comments=SOURCE_COMMENTS)
return compile(filename=self.filename,
output_style=OUTPUT_STYLE,
source_comments=SOURCE_COMMENTS)
else:
return compile(string=self.content)
return compile(string=self.content,
output_style=OUTPUT_STYLE)

0 comments on commit dae35e3

Please sign in to comment.