mr_app
mr_app

Reputation: 1312

Less.php parse and overwrite variable

Is it possible to overwrite an existing varibale via a sent parameter?

Example: My CSS

/* ... */
@bg_color: purple;
@h_color: lighten(@bg_color,25);
#header { background: @bg_color; }
/* ... */

Now when I call:

$less->parse(array('bg_color' => 'blue'));

it has no effect. The variable will not be overwritten. The idea is to use the variable in the CSS as a "Fallback-Color"

Any ideas how I can force less.php to overwrite existing variables?

Upvotes: 0

Views: 546

Answers (2)

mr_app
mr_app

Reputation: 1312

The answer: less.php canot overwrite less-variables!

Upvotes: 0

complex857
complex857

Reputation: 20753

I think you calling the parse() method wrong, the current signature of git-master is:

function parse($str = null, $initialVariables = null) {

It's since the 3.x.x version, prior to that (2.0.0 tag) it had only the $str parameter, (actual change commit of that line is here).

As for overwriting: The way lessc parses your code is that it pushes the variables you give them in phpland and then reads the source less file. The source less file will always take precedence because of that, you can't load a less file for compilation and change variables in them within them before lessc generates output.

Upvotes: 1

Related Questions