leafo/lessphp — Issue #165: Allow parsing of multiple files
Author: quassy
Created: 2011-12-18 18:21:44+00:00
State: open

I already posted this some time ago, but I guess this is the better place for you to take notice.

lessphp should be able to handle multiple input files (not only by using @import), hence I modified lessc::ccompile().

```php
class less extends lessc {

// compile $in to $out if $in is newer than $out
// returns true when it compiles, false otherwise
// now takes multiple arguments for $in

public static function ccompile($in, $out) {
$compile = false;
if (!is_array($in)) {
$in = array($in);
}
foreach ($in as $r) {
if (filemtime($r) > filemtime($out)) {
$compile = true;
break;
}
}

if (!is_file($out) || $compile) {
$contents = '';
foreach ($in as $r) {
$contents .= file_get_contents($r);
}

$file = './css/less.tmp';
file_put_contents($file, $contents);

$less = new lessc($file);
$code = $less->parse();
/*
You may include CssMin to decrease filesize by 10-20%

@package CssMin
@author Joe Scylla
@license MIT License
@link http://code.google.com/p/cssmin/
*/
if (class_exists('CssMin')) {
$code = CssMin::minify($code);
}

file_put_contents($out, $code);

return true;
}
return false;
}

}
```