Commit 2213f77d by Timothée Peignier

add less compiler

parent bca184da
from compress.conf import settings
from compress.compilers import CompilerBase
class LessCompiler(CompilerBase):
def match_file(self, filename):
return filename.endswith('.less')
def compile_file(self, content):
tmp_file = tempfile.NamedTemporaryFile(mode='w+b')
tmp_file.write(css)
tmp_file.flush()
output_file = tempfile.NamedTemporaryFile(mode='w+b')
command = '%s %s %s %s' % (
settings.COMPRESS_LESS_BINARY, tmp_file.name,
settings.COMPRESS_LESS_ARGUMENTS, output_file.name
)
command_output = os.popen(command).read()
compiled_content = output_file.read()
output_file.close()
tmp_file.close()
if self.verbose:
print command_output
return compiled_content
......@@ -41,6 +41,9 @@ COMPRESS_COFFEE_SCRIPT_ARGUMENTS = getattr(settings, 'COFFEE_SCRIPT_ARGUMENTS',
COMPRESS_SASS_BINARY = getattr(settings, 'COMPRESS_SASS_BINARY', '/usr/local/bin/sass')
COMPRESS_SASS_ARGUMENTS = getattr(settings, 'COMPRESS_SASS_ARGUMENTS', '--scss')
COMPRESS_LESS_BINARY = getattr(settings, 'COMPRESS_LESS_BINARY', '/usr/local/bin/lessc')
COMPRESS_LESS_ARGUMENTS = getattr(settings, 'COFFEE_LESS_ARGUMENTS', '')
if COMPRESS_CSS_COMPRESSORS is None:
COMPRESS_CSS_COMPRESSORS = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment