Skip to content

Instantly share code, notes, and snippets.

@jorilallo
Last active December 19, 2015 23:29
Show Gist options
  • Select an option

  • Save jorilallo/6035248 to your computer and use it in GitHub Desktop.

Select an option

Save jorilallo/6035248 to your computer and use it in GitHub Desktop.
COMPRESS_PRECOMPILERS = (
('text/coffeescript', 'coffee --compile --stdio'),
('text/x-scss', 'python manage.py template_filter {infile} | sass --scss --stdin {outfile}'),
)
COMPRESS_CSS_FILTERS = ['compressor.filters.cssmin.CSSMinFilter']
from django.core.management.base import BaseCommand, CommandError
from django.contrib.staticfiles import finders
from django.template import Template, Context
from django.conf import settings
class Command(BaseCommand):
args = '<input_file.scss>'
def handle(self, *args, **options):
if len(args) != 1:
raise CommandError('Give filename as argument')
filename = args[0]
template = Template(open(finders.find(filename)).read())
context = Context(settings.COMPRESS_TEMPLATE_FILTER_CONTEXT)
data = template.render(context)
self.stdout.write(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment