Community Documentation

LESS CSS Preprocessor

Last updated November 1, 2012. Created by corey.aufang on October 9, 2012.
Edited by Noe_. Log in to edit this page.

Documentation for the LESS CSS Preprocessor module.

Built using the lessphp library by Leaf Corcoran.

This module will automatically process any LESS files that are added using drupal_add_css or added through your module/theme's .info file.

Add your files just like any other .css file, just with .less as the extension, and they will be automatically processed.

Requirements

  • Libraries API.
  • lessphp library unpacked so that 'lessc.inc.php' is located at 'sites/all/libraries/lessphp/lessc.inc.php'.

LESS Development:

Syntax

http://leafo.net/lessphp/docs/

File placement

If your source file was "sites/all/modules/test/test.css.less"
Then your compiled file will be "sites/[yoursite_or_default]/files/less/[random.string]/sites/all/modules/test/test.css"

Use:

The following two examples provide equivalent functionality.

drupal_add_css:

<?php
$module_path
= drupal_get_path('module', 'less_demo');
drupal_add_css($module_path . '/styles/less_demo.css.less');
?>

.info file:

stylesheets[all][] = styles/less_demo.css.less

Compatibility:

Should work with most themes and caching mechanisms.

CSS Aggregation

Fully compatible with "Optimize CSS files" setting on "Admin->Site configuration->Performance" (admin/settings/performance).

RTL Support

RTL support will work as long as your file names end with ".css.less".

Assuming your file is named "somename.css.less", Drupal automatically looks for a file name "somename-rtl.css.less"

Contributed Modules

Confirmed to work with:

Page status

About this page

Drupal version
Drupal 6.x, Drupal 7.x
Level
Beginner, Intermediate, Advanced
Audience
Designers/themers, Site administrators, Site builders
Keywords
css, less, preprocessor

Site Building Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here