Giter Site home page Giter Site logo

linssen / django-libsass Goto Github PK

View Code? Open in Web Editor NEW

This project forked from torchbox/django-libsass

0.0 3.0 0.0 117 KB

A django-compressor filter to compile SASS files using libsass

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

django-libsass's Introduction

django-libsass

A django-compressor filter to compile Sass files using libsass.

Installation

Starting from a Django project with django-compressor set up:

pip install django-libsass

and add django_libsass.SassCompiler to your COMPRESS_PRECOMPILERS setting:

COMPRESS_PRECOMPILERS = (
    ('text/x-scss', 'django_libsass.SassCompiler'),
)

You can now use the content type text/x-scss on your stylesheets, and have them compiled seamlessly into CSS:

{% compress css %}
    <link rel="stylesheet" type="text/x-scss" href="{% static "myapp/css/main.scss" %}" />
{% endcompress %}

Imports

Relative paths in @import lines are followed as you would expect:

@import "../variables.scss";

Additionally, Django's STATICFILES_FINDERS setting is consulted, and all possible locations for static files on the local filesystem are included on the search path. This makes it possible to import files across different apps:

@import "myotherapp/css/widget.scss"

Why django-libsass?

We wanted to use Sass in a Django project without introducing any external (non pip-installable) dependencies. (Actually, we wanted to use Less, but the same arguments apply...) There are a few pure Python implementations of Sass and Less, but we found that they invariably didn't match the behaviour of the reference compilers, either in their handling of @imports or lesser-used CSS features such as media queries.

libsass is a mature C/C++ port of the Sass engine, co-developed by the original creator of Sass, and we can reasonably rely on it to stay in sync with the reference Sass compiler - and, being C/C++, it's fast. Thanks to Hong Minhee's libsass-python project, it has Python bindings and installs straight from pip.

django-libsass builds on libsass-python to make @import paths aware of Django's staticfiles mechanism, and provides a filter module for django-compressor which uses the libsass-python API directly, avoiding the overheads of calling an external executable to do the compilation.

Author

Matt Westcott [email protected]

django-libsass's People

Contributors

cassus avatar gasman avatar linssen avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.