django-pyscss
-------------
A collection of tools for making it easier to use pyScss within Django.
.. image:: https://travis-ci.org/fusionbox/django-pyscss.png
:target: http://travis-ci.org/fusionbox/django-pyscss
:alt: Build Status
.. image:: https://coveralls.io/repos/fusionbox/django-pyscss/badge.png?branch=master
:target: https://coveralls.io/r/fusionbox/django-pyscss
:alt: Coverage Status
.. note::
This version only supports pyScss 1.3.4 and greater. For pyScss 1.2 support,
you can use the 1.x series of django-pyscss.
Installation
============
django-pyscss supports Django 1.4+, and Pythons 2 and 3.
You may install django-pyscss off of PyPI::
pip install django-pyscss
Why do we need this?
====================
This app smooths over a lot of things when dealing with pyScss in Django. It
- Overwrites the import system to use Django's staticfiles app. This way you
can import SCSS files from any app (or any file that's findable by the
STATICFILES_FINDERS) with no hassle.
- Configures pyScss to work with the staticfiles app for its image functions
(e.g. inline-image and sprite-map).
- It provides a django-compressor precompile filter class so that you can
easily use pyScss with django-compressor without having to bust out to the
shell. This has the added benefit of removing the need to configure pyScss
through its command-line arguments AND makes it possible for the exceptions
and warnings that pyScss emits to bubble up to your process so that you can
actually know what's going on.
Rendering SCSS manually
=======================
You can render SCSS manually from a string like this:
.. code-block:: python
from django_pyscss import DjangoScssCompiler
compiler = DjangoScssCompiler()
compiler.compile_string(".foo { color: green; }")
You can render SCSS from a file like this:
.. code-block:: python
from django_pyscss import DjangoScssCompiler
compiler = DjangoScssCompiler()
compiler.compile('css/styles.scss')
The file needs to be able to be located by staticfiles finders in order to be
used.
The ``DjangoScssCompiler`` class is a subclass of ``scss.Compiler`` that
injects the ``DjangoExtension``. ``DjangoExtension`` is what overrides the
import mechanism.
``DjangoScssCompiler`` also turns on the CompassExtension by default, if you
wish to turn this off you do so:
.. code-block:: python
from django_pyscss import DjangoScssCompiler
from django_pyscss.extensions.django import DjangoExtension
compiler = DjangoScssCompiler(extensions=[DjangoExtension])
For a list of options that ``DjangoScssCompiler`` accepts, please see the
pyScss `API documentation <http://pyscss.readthedocs.org/en/latest/python-api.html#new-api>`_.
Using in conjunction with django-compressor
===========================================
django-pyscss comes with support for django-compressor. All you have to do is
add it to your ``COMPRESS_PRECOMPILERS`` setting. :
.. code-block:: python
COMPRESS_PRECOMPILERS = (
# ...
('text/x-scss', 'django_pyscss.compressor.DjangoScssFilter'),
# ...
)
Then you can just use SCSS like you would use CSS normally. :
.. code-block:: html+django
{% compress css %}
<link rel="stylesheet" type="text/x-scss" href="{% static 'css/styles.css' %}">
{% endcompress %}
If you wish to provide your own compiler instance (for example if you wanted to
change some settings on the ``DjangoScssCompiler``), you can subclass
``DjangoScssFilter``. :
.. code-block:: python
# myproject/scss_filter.py
from django_pyscss import DjangoScssCompiler
from django_pyscss.compressor import DjangoScssFilter
class MyDjangoScssFilter(DjangoScssFilter):
compiler = DjangoScssCompiler(
# Example configuration
output_style='compressed',
)
# settings.py
COMPRESS_PRECOMPILERS = (
# ...
('text/x-scss', 'myproject.scss_filter.MyDjangoScssFilter'),
# ...
)
Running the tests
=================
You can run the tests by running.
$ python setup.py test
Please note that this will collecstatic into ``tmp/static/`` automatically as
some of the tests require the staticfiles to have been collected.
CHANGELOG
---------
2.0.3 (2023-08-30)
==================
- Support for Django 4.2. Drop support for Python 2.
2.0.2 (2015-04-29)
==================
- Fixed bug with relative imports [#34, #35 r1chardj0n3s]
2.0.1 (2015-04-23)
==================
- Explicitly depend on pathlib, instead of assuming pyScss will require it. [#33]
- Fixed cases where DEBUG is False but collectstatic hasn't been run (common in tests).
2.0.0 (2015-04-22)
==================
- Added support for pyScss 1.3 and Python 3.
- Dropped support for pyScss 1.2
Upgrade path
^^^^^^^^^^^^
If you are just using the django-compressor integration, you don't have to
upgrade anything.
If you were using the ``DjangoScss`` class directly, it has been replaced with
the ``DjangoScssCompiler`` class. The API for compiling CSS has changed as
well, for example, to compile from a string, previously you would do it like
this:
.. code-block:: python
>>> from django_pyscss.scss import DjangoScss
>>> compiler = DjangoScss()
>>> compiler.compile(".foo { color: red; }")
Now the interface is like this:
.. code-block:: python
>>> from django_pyscss import DjangoScssCompiler
>>> compiler = DjangoScssCompiler()
>>> compiler.compile_string(".foo { color: red; }")
You read more about the new API on the `pyScss API documentation
<http://pyscss.readthedocs.org/en/latest/python-api.html#new-api>`_.
1.0.0 - 2014-02-11
==================
Released django-pyscss.
Raw data
{
"_id": null,
"home_page": "https://github.com/fusionbox/django-pyscss",
"name": "django-pyscss",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "django css scss sass pyscss compressor",
"author": "Fusionbox, Inc.",
"author_email": "programmers@fusionbox.com",
"download_url": "https://files.pythonhosted.org/packages/fc/71/75737fc65a3563ead1fb60ccad5459cf2342f2fc009006294e8f78d04c1e/django-pyscss-2.0.3.tar.gz",
"platform": null,
"description": "django-pyscss\n-------------\n\nA collection of tools for making it easier to use pyScss within Django.\n\n.. image:: https://travis-ci.org/fusionbox/django-pyscss.png\n :target: http://travis-ci.org/fusionbox/django-pyscss\n :alt: Build Status\n\n.. image:: https://coveralls.io/repos/fusionbox/django-pyscss/badge.png?branch=master\n :target: https://coveralls.io/r/fusionbox/django-pyscss\n :alt: Coverage Status\n\n\n.. note::\n\n This version only supports pyScss 1.3.4 and greater. For pyScss 1.2 support,\n you can use the 1.x series of django-pyscss.\n\n\nInstallation\n============\n\ndjango-pyscss supports Django 1.4+, and Pythons 2 and 3.\n\nYou may install django-pyscss off of PyPI::\n\n pip install django-pyscss\n\n\nWhy do we need this?\n====================\n\nThis app smooths over a lot of things when dealing with pyScss in Django. It\n\n- Overwrites the import system to use Django's staticfiles app. This way you\n can import SCSS files from any app (or any file that's findable by the\n STATICFILES_FINDERS) with no hassle.\n\n- Configures pyScss to work with the staticfiles app for its image functions\n (e.g. inline-image and sprite-map).\n\n- It provides a django-compressor precompile filter class so that you can\n easily use pyScss with django-compressor without having to bust out to the\n shell. This has the added benefit of removing the need to configure pyScss\n through its command-line arguments AND makes it possible for the exceptions\n and warnings that pyScss emits to bubble up to your process so that you can\n actually know what's going on.\n\n\nRendering SCSS manually\n=======================\n\nYou can render SCSS manually from a string like this:\n\n.. code-block:: python\n\n from django_pyscss import DjangoScssCompiler\n\n compiler = DjangoScssCompiler()\n compiler.compile_string(\".foo { color: green; }\")\n\nYou can render SCSS from a file like this:\n\n.. code-block:: python\n\n from django_pyscss import DjangoScssCompiler\n\n compiler = DjangoScssCompiler()\n compiler.compile('css/styles.scss')\n\nThe file needs to be able to be located by staticfiles finders in order to be\nused.\n\nThe ``DjangoScssCompiler`` class is a subclass of ``scss.Compiler`` that\ninjects the ``DjangoExtension``. ``DjangoExtension`` is what overrides the\nimport mechanism.\n\n``DjangoScssCompiler`` also turns on the CompassExtension by default, if you\nwish to turn this off you do so:\n\n.. code-block:: python\n\n from django_pyscss import DjangoScssCompiler\n from django_pyscss.extensions.django import DjangoExtension\n\n compiler = DjangoScssCompiler(extensions=[DjangoExtension])\n\nFor a list of options that ``DjangoScssCompiler`` accepts, please see the\npyScss `API documentation <http://pyscss.readthedocs.org/en/latest/python-api.html#new-api>`_.\n\n\nUsing in conjunction with django-compressor\n===========================================\n\ndjango-pyscss comes with support for django-compressor. All you have to do is\nadd it to your ``COMPRESS_PRECOMPILERS`` setting. :\n\n.. code-block:: python\n\n COMPRESS_PRECOMPILERS = (\n # ...\n ('text/x-scss', 'django_pyscss.compressor.DjangoScssFilter'),\n # ...\n )\n\nThen you can just use SCSS like you would use CSS normally. :\n\n.. code-block:: html+django\n\n {% compress css %}\n <link rel=\"stylesheet\" type=\"text/x-scss\" href=\"{% static 'css/styles.css' %}\">\n {% endcompress %}\n\nIf you wish to provide your own compiler instance (for example if you wanted to\nchange some settings on the ``DjangoScssCompiler``), you can subclass\n``DjangoScssFilter``. :\n\n.. code-block:: python\n\n # myproject/scss_filter.py\n from django_pyscss import DjangoScssCompiler\n from django_pyscss.compressor import DjangoScssFilter\n\n class MyDjangoScssFilter(DjangoScssFilter):\n compiler = DjangoScssCompiler(\n # Example configuration\n output_style='compressed',\n )\n\n # settings.py\n COMPRESS_PRECOMPILERS = (\n # ...\n ('text/x-scss', 'myproject.scss_filter.MyDjangoScssFilter'),\n # ...\n )\n\n\nRunning the tests\n=================\n\nYou can run the tests by running.\n\n $ python setup.py test\n\nPlease note that this will collecstatic into ``tmp/static/`` automatically as\nsome of the tests require the staticfiles to have been collected.\n\n\nCHANGELOG\n---------\n\n\n2.0.3 (2023-08-30)\n==================\n\n- Support for Django 4.2. Drop support for Python 2.\n\n\n2.0.2 (2015-04-29)\n==================\n\n- Fixed bug with relative imports [#34, #35 r1chardj0n3s]\n\n\n2.0.1 (2015-04-23)\n==================\n\n- Explicitly depend on pathlib, instead of assuming pyScss will require it. [#33]\n- Fixed cases where DEBUG is False but collectstatic hasn't been run (common in tests).\n\n\n2.0.0 (2015-04-22)\n==================\n\n- Added support for pyScss 1.3 and Python 3.\n- Dropped support for pyScss 1.2\n\nUpgrade path\n^^^^^^^^^^^^\n\nIf you are just using the django-compressor integration, you don't have to\nupgrade anything.\n\nIf you were using the ``DjangoScss`` class directly, it has been replaced with\nthe ``DjangoScssCompiler`` class. The API for compiling CSS has changed as\nwell, for example, to compile from a string, previously you would do it like\nthis:\n\n.. code-block:: python\n\n >>> from django_pyscss.scss import DjangoScss\n >>> compiler = DjangoScss()\n >>> compiler.compile(\".foo { color: red; }\")\n\nNow the interface is like this:\n\n.. code-block:: python\n\n >>> from django_pyscss import DjangoScssCompiler\n >>> compiler = DjangoScssCompiler()\n >>> compiler.compile_string(\".foo { color: red; }\")\n\nYou read more about the new API on the `pyScss API documentation\n<http://pyscss.readthedocs.org/en/latest/python-api.html#new-api>`_.\n\n\n1.0.0 - 2014-02-11\n==================\n\nReleased django-pyscss.\n",
"bugtrack_url": null,
"license": "",
"summary": "Makes it easier to use PySCSS in Django.",
"version": "2.0.3",
"project_urls": {
"Homepage": "https://github.com/fusionbox/django-pyscss"
},
"split_keywords": [
"django",
"css",
"scss",
"sass",
"pyscss",
"compressor"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fc7175737fc65a3563ead1fb60ccad5459cf2342f2fc009006294e8f78d04c1e",
"md5": "782f38a1414814308a08da517e1c383e",
"sha256": "b976c357579620bf21a10152a863d30f66bb628cd4f99def95955fc8581e36d2"
},
"downloads": -1,
"filename": "django-pyscss-2.0.3.tar.gz",
"has_sig": false,
"md5_digest": "782f38a1414814308a08da517e1c383e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 18209,
"upload_time": "2023-08-30T22:59:07",
"upload_time_iso_8601": "2023-08-30T22:59:07.017256Z",
"url": "https://files.pythonhosted.org/packages/fc/71/75737fc65a3563ead1fb60ccad5459cf2342f2fc009006294e8f78d04c1e/django-pyscss-2.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-30 22:59:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "fusionbox",
"github_project": "django-pyscss",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "django-pyscss"
}