Permalink
Browse files

Add option to specify compression type.

  • Loading branch information...
1 parent 27c3007 commit f386b606e126b9080b876467b405ac94329a4e97 @MrTravisB committed Apr 26, 2012
Showing with 15 additions and 5 deletions.
  1. +2 −2 README.md
  2. +11 −2 lesscss/__init__.py
  3. +2 −1 setup.py
View
@@ -23,8 +23,8 @@ Sample Brubeck and web.py projects are in `examples` folder.
- **exclude_dirs**: Directories you don't want to be searched. It'd be pointless to search for `less` files in an images directory. This parameter is expected to be a list.
- **based**: If it's set `True` then LessCSS will generate the `style-(base60).css` version as well (for example; `style-dHCFD.css`). This is useful if you set expire times of static files to a distant future since browsers will not retrieve those files unless the name is different or the cache has expired. This parameter is expected to be a boolean value.
- **compressed**: If it's set `True` then LessCSS will minimize the generated CSS files. This parameter is expected to be a boolean value.
-- **output_dir**: Absolute path of the folder where compiled CSS files
-should be put.
+- **compression**: Specifies the type of compression to use. Default to the normal compression, 'x'. Other option is to use the [YUI Compressor](http://developer.yahoo.com/yui/compressor/css.html), 'yui'. See "Command-line Usage" at http://lesscss.org/.
+- **output_dir**: Absolute path of the folder where compiled CSS files should be put.
##TODO
View
@@ -27,7 +27,7 @@ class LessCSS(object):
"""
def __init__(self, media_dir='static', exclude_dirs=None, based=True,
- compressed=True, output_dir=None):
+ compressed=True, compression='x', output_dir=None):
""" Initialize LessCSS. When you wrap your web application you need to
define the following parameters:
@@ -50,7 +50,13 @@ def __init__(self, media_dir='static', exclude_dirs=None, based=True,
``compressed``
If this is set to `True`, then the compiled CSS file will be
minimized.
-
+
+ ``compression``
+ The type of compression to use. Default to standard 'x' compression.
+ Set to 'yui' to use YUI Compressor
+ (http://developer.yahoo.com/yui/compressor/css.html).
+ See "Command-line Usage" at http://lesscss.org/
+
``output_dir``
Define the absolute path of the folder where compiled CSS files
should be put.
@@ -59,6 +65,7 @@ def __init__(self, media_dir='static', exclude_dirs=None, based=True,
self._media = media_dir
self._based = based
self._compressed = compressed
+ self._compression = compression
self._excluded = exclude_dirs
self._output = output_dir.rstrip('/') if output_dir else None
self.compile()
@@ -109,6 +116,8 @@ def compile(self):
command_opt = ['lessc', '-x']
if not self._compressed:
del command_opt[-1]
+ if self._compressed and self._compression.lower() == 'yui':
+ command_opt[1] = '--yui-compress'
for i in less:
filename = os.path.splitext(i)[0]
css = '%s.css' % filename
View
@@ -30,7 +30,7 @@
::
from lesscss import LessCSS
- LessCSS(media_dir='media', exclude_dirs=['img', 'src'], based=True, compressed=True, output_dir=None)
+ LessCSS(media_dir='media', exclude_dirs=['img', 'src'], based=True, compressed=True, compression='x', output_dir=None)
Parameters
@@ -40,6 +40,7 @@
- **exclude_dirs:** Directories you don't want to be searched. It'd be pointless to search for less files in an images directory. This parameter is expected to be a list.
- **based:** If it's set True then LessCSS will generate the style-(base60).css version as well (for example; style-dHCFD.css). This is useful if you set expire times of static files to a distant future since browsers will not retrieve those files unless the name is different or the cache has expired. This parameter is expected to be a boolean value.
- **compressed**: If it's set `True` then LessCSS will minimize the generated CSS files. This parameter is expected to be a boolean value.
+- **compression**: Specifies the type of compression to use. Default to the normal compression, 'x'. Other option is to use the [YUI Compressor](http://developer.yahoo.com/yui/compressor/css.html), 'yui'. See "Command-line Usage" at http://lesscss.org/.
- **output_dir:** Directory where you put compiled CSS files if different than location of .less file.

0 comments on commit f386b60

Please sign in to comment.