lessphp icon indicating copy to clipboard operation
lessphp copied to clipboard

How to load variables file that overrided by setVariables ?

Open qaharmdz opened this issue 10 years ago • 2 comments

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 avatar Jan 28 '16 12:01 qaharmdz

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;
}

qaharmdz avatar Jan 30 '16 07:01 qaharmdz

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.

rockneverdies55 avatar Dec 30 '18 14:12 rockneverdies55