leafo / lessphp

LESS compiler written in PHP
http://leafo.net/lessphp
Other
2.2k stars 529 forks source link

How to load variables file that overrided by setVariables ? #622

Open qaharmdz opened 8 years ago

qaharmdz commented 8 years ago

My code

// PHP
$less = new lessc;
$less->setVariables(array(
    'font-color' => '#333,
));
$less->compileFile($path . 'less/test.less', $path . 'test.css');

// LESS
@import "variables.less"; // font-color here #111
body {
  color: @font-color;
}

// Output
body {
    color: #111; // Expecting #333
}

I'm expecting the body color to be 333

Any help is appreciated

qaharmdz commented 8 years ago

It would be awesome if we have loadVariables($file) to load variable file(s)

$less = new lessc;
$less->loadVariables($path . 'less/variable.less'); // @font-color: #111
$less->setVariables(array(
    'font-color' => '#333,
));
$less->compileFile($path . 'less/test.less', $path . 'test.css');

// LESS
body {
  color: @font-color;
}

// Output
body {
    color: #333;
}
rockneverdies55 commented 5 years ago

Wow. It's been almost 2 years and no response at all :open_mouth: I guess it's not possible to callsetVariables first and then compile file with those variables/values.