Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client use - Variables #2132

Closed
Jamtis opened this issue Aug 1, 2014 · 2 comments
Closed

Client use - Variables #2132

Jamtis opened this issue Aug 1, 2014 · 2 comments

Comments

@Jamtis
Copy link

Jamtis commented Aug 1, 2014

.complementary-hsla(@name, @hue, @saturation, @lightness, @alpha) {
  @{name}: hsla(@hue, @saturation, @lightness, @alpha);
  @{name}-inverse: hsla(360 - @hue, 100% - @saturation, 100% - @lightness, 1 - @alpha);
}

.complementary-hsla("@text-color", 0, 0%, 0%, .73);

.class {
    color: @text-color;
    background: @text-color-inverse;
}

breaks the current client version 1.7.4 but compiles fine in 1.6.0 to

.class {
  color: rgba(0, 0, 0, 0.73);
  background: rgba(255, 255, 255, 0.27);
}

Error message is NameError: variable @text-color is undefined.

@seven-phases-max
Copy link
Member

I'm afraid this was just a bug in 1.6.0. There's no such Less feature as "defining a variable with name defined in another variable", i.e. this:

@name: "@whatever";
@{name}: 123;

is supposed to be compiled to

"@whatever": 123;

as expected.

Note that @{var}: 123 syntax is added for Property Interpolation only (you should not use it to define a new variables).

Curiously, your code still will compile with current Less versions if you change "@text-color" to ~"@text-color" but yet again this is no more than just unintentional bogus - this "feature" is not officially supported and not guaranteed to work in next releases.

@seven-phases-max
Copy link
Member

Closing as "expected behaviour" (the related bug though is raised in #2133).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants