NAME

CSS::LESS - Compile LESS stylesheet files (.less) using lessc

SYNOPSIS

use CSS::LESS;
# Compile a single LESS stylesheet
my $less = CSS::LESS->new();
my $css = $less->compile('a:link { color: lighten('#000000', 10%); }');
print $css."\n";

# Compile a LESS stylesheets with using @include syntax of LESS.
$less = CSS::LESS->new( include_paths => ['/foo/include/'] );
$css = $less->compile('@import (less) 'bar.less'; div { width: 100px; }');
print $css."\n";

This module has released as an alpha version.

REQUIREMENTS

lessc

It must installed, because this module is wrapper of "lessc".

You can install "lessc" using "npm" (Node.js Package Manager).

$ npm install -g less
$ lessc -v
lessc x.x.x (LESS Compiler) [JavaScript]

INSTALLATION (from GitHub)

$ git clone git://github.com/mugifly/p5-CSS-LESS.git
$ cpanm ./p5-CSS-LESS

METHODS

new ( [%params] )

Create an instance of CSS::LESS.

%params :

include_paths

Path of include .less files.

This paths will be used for the @include syntax of .less stylesheet.

Use case of example:

# File-A of LESS stylesheet
# This file will be set as content when calling a 'compile' method.
@include (less) 'foo.less';
~~~~

# File-B of LESS stylesheet
# This file was already saved to: /var/www/include/foo.less
div {
  width: (100+200)px;
}
~~~~

# Example of script
my less = CSS::LESS->new( include_paths => [ '/var/www/include/' ] )
my $css = $less->compile( File-A ); # Let compile the File-A.
print $css."\n"; # It includes the File-B, and will be compiled.
compress

Compress a compiled style-sheet. It means removing some whitespaces using lessc. (default: 0)

Avaiable value: 1 or 0. This item is same as parameter of lessc.

strict_imports

Force evaluation of imports. (default: 0)

Avaiable value: 1 or 0. This item is same as parameter of lessc.

relative_urls

Re-write relative urls to the base LESS stylesheet. (default: undef)

Avaiable value: 1 or 0. This item is same as parameter of lessc.

rootpath

Set rootpath for url rewriting in relative imports and urls. (default: undef)

This item is same as parameter of lessc.

line_numbers

Outputs filename and line numbers. (default: undef)

Avalable value: 'comments', 'mediaquery', 'both', undef.

This item is same as parameter of lessc.

lessc_path

Path of LESS compiler (default: 'lessc' on the PATH.)

dry_run

Dry-run mode for debug. (default: 0)

dont_die

When an errors accrued, don't die. (default: 0)

tmp_path

Path of save for temporally files. (default: '/tmp/'' or other temporally directory.)

compile ( $content [, %params] )

Parse a LESS (.less) stylesheet, and compile to CSS (.css) stylesheet.

In addition, If you would prefer to compile from a file, firstly, please read a file with using the "File::Slurp" module or open method as simply. Then, parse it with this 'compile' method.

$content

Content of LESS (.less) stylesheet.

%params

This item is optional. You can use parameters same as %params of new(...) method.

is_lessc_installed ( )

Check for lessc has installed.

last_error ()

Get a message of last error. (This method is useful only if 'dont_die' parameter is set when initialized an instance.)

SEE ALSO

https://github.com/mugifly/p5-CSS-LESS - Develop on GitHub. Your feedback is highly appreciated.

CSS::LESSp - LESS-parser by native perl implementation.

CSS::Sass

COPYRIGHT AND LICENSE

Copyright (C) 2013, Masanori Ohgita (http://ohgita.info/).

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.