oyejorge / less.php

less.js ported to PHP.
http://lessphp.typesettercms.com
Apache License 2.0
656 stars 2 forks source link

Undefined property: Less_Tree_Color::$value #318

Closed gerardreches closed 8 years ago

gerardreches commented 8 years ago

I get an _Undefined property: Less_TreeColor::$value exception with this code:

@black: #000000;
@white: #ffffff;
@color_list: black, white;

.generate-color-system(length(@color_list));

.generate-color-system(@number, @i: 1) when (@i =< @number) {
    @name: extract(@color_list, @i);

    .bg-@{name} { background-color: @@name; }

    .generate-color-system(@number, (@i + 1));
}

This code is compiled correctly at lesscss.org demo but not in my project and neither on less.php demo (here it throws variable @ is undefined).

Am I missing something? Is there a workaround?

EDIT: If I change background-color: @@name; to background-color: @name; it works on less.php but not in Less.

seven-phases-max commented 8 years ago

In Less before v2.x, the color keywords (i.e .black and white in your example) were always interpreted as actual color values (and never as generic identifiers). For more details see https://github.com/less/less.js/issues/1595.

Workaround: use escaping, e.g. ~'black' and ~'white'.

gerardreches commented 8 years ago

Thanks Max :+1: So less.php compiles in a previous version than 2.x ?

seven-phases-max commented 8 years ago

It's (the latest version) less or more equal to 1.7.x (actually its version -> Less version + "build number").

dhduc commented 7 years ago

I've compiled LESS on Magento 2, the bug happens when using @@variable instead of right way is @variable.

kevnk commented 4 years ago

I got this error in Magento 2 when I call a LESS function and passed in a variable without making it a string: escape(@variable) caused an error; escape("@{variable}") removed the error