Skip to content

Commit 87038de

Browse files
ccwang002gasman
authored andcommitted
Set SASS numerical precision via LIBSASS_PRECISION
Added settings.LIBSASS_PRECISION, which accepts an int to change the default precision for numbers. For example, # settings.py LIBSASS_PRECISION = 10 will increase the numerical precision to 10 digits, default being 5.
1 parent 7dc3ae4 commit 87038de

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

CHANGELOG.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Changelog
22
=========
33

4+
0.7 (xx.xx.xxxx)
5+
~~~~~~~~~~~~~~~~
6+
* Added LIBSASS_PRECISION setting (Liang-Bo Wang)
7+
48
0.6 (21.11.2015)
59
~~~~~~~~~~~~~~~~
610
* Fixed call to FilterBase super for django-compressor 1.6 compatibility (Dennis Vermeulen)

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The following settings can be used to control django-libsass's behaviour:
4747
* ``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.
4848
* ``LIBSASS_CUSTOM_FUNCTIONS`` - A mapping of custom functions to be made available within the SASS compiler. By default, a ``static`` function is provided, analogous to Django's ``static`` template tag.
4949
* ``LIBSASS_SOURCEMAPS`` - Enable embedding sourcemaps into file output.
50+
* ``LIBSASS_PRECISION`` - Number of digits of numerical precision (default: 5)
5051

5152
Custom functions
5253
~~~~~~~~~~~~~~~~

django_libsass.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def static(path):
2323
SOURCE_COMMENTS = getattr(settings, 'LIBSASS_SOURCE_COMMENTS', settings.DEBUG)
2424
CUSTOM_FUNCTIONS = getattr(settings, 'LIBSASS_CUSTOM_FUNCTIONS', {'static': static})
2525
SOURCEMAPS = getattr(settings, 'LIBSASS_SOURCEMAPS', False)
26+
PRECISION = getattr(settings, 'LIBSASS_PRECISION', None) # None use libsass default
2627

2728

2829
INCLUDE_PATHS = None # populate this on first call to 'get_include_paths'
@@ -102,6 +103,8 @@ def embed_sourcemap(output, sourcemap):
102103
def compile(**kwargs):
103104
"""Perform sass.compile, but with the appropriate include_paths for Django added"""
104105
kwargs = kwargs.copy()
106+
if PRECISION is not None:
107+
kwargs['precision'] = PRECISION
105108
kwargs['include_paths'] = (kwargs.get('include_paths') or []) + get_include_paths()
106109

107110
custom_functions = CUSTOM_FUNCTIONS.copy()

0 commit comments

Comments
 (0)