CSS::LESS - Compile LESS stylesheet files (.less) using lessc
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.
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]
$ git clone git://github.com/mugifly/p5-CSS-LESS.git $ cpanm ./p5-CSS-LESS
Create an instance of CSS::LESS.
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)
relative_urls
Re-write relative urls to the base LESS stylesheet. (default: undef)
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.
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.)
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 of LESS (.less) stylesheet.
This item is optional. You can use parameters same as %params of new(...) method.
Check for lessc has installed.
Get a message of last error. (This method is useful only if 'dont_die' parameter is set when initialized an instance.)
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 (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.
To install CSS::LESS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CSS::LESS
CPAN shell
perl -MCPAN -e shell install CSS::LESS
For more information on module installation, please visit the detailed CPAN module installation guide.