LessCSS is a helper which automatically compiles LESS files to CSS whenever the LESS files are modified.
It works with Brubeck and web.py web frameworks. Although it's not tested on other frameworks such as bottle, it should work without any problems.
Sample Brubeck and web.py projects are in
Note: You need to install
less before using this helper.
$ pip install lesscss
from lesscss import LessCSS LessCSS(media_dir='media', exclude_dirs=['img', 'js'], based=True)
- media_dir: Directory where you put static/media files such as css/js/img.
- exclude_dirs: Directories you don't want to be searched. It'd be pointless to search for
lessfiles in an images directory. This parameter is expected to be a list.
- based: If it's set
Truethen LessCSS will generate the
style-(base60).cssversion 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
Truethen 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, 'yui'. See "Command-line Usage" at http://lesscss.org/.
- output_dir: Absolute path of the folder where compiled CSS files should be put.
- Automatically set CSS name in HTML templates.
Released under BSD, see LICENSE for details.
Code is based on Steve Losh's flask-lesscss.