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

selector string interpolation converts color keywords to hex #692

Closed
neonstalwart opened this issue Mar 7, 2012 · 5 comments
Closed

selector string interpolation converts color keywords to hex #692

neonstalwart opened this issue Mar 7, 2012 · 5 comments

Comments

@neonstalwart
Copy link
Contributor

while adding the test for #691, i found a possible bug.

@theme: red;
~".@{theme}" {
  color: red;
}

produces

.#ff0000 {
  color: red;
}

when i would have hoped it would be

.red {
  color: red;
}
@Kalyse
Copy link

Kalyse commented Mar 13, 2012

Because red is a color and you aren't interpetting it as a string, it is falling back to any of the colors contained in less/tree/colors.js.

The fix, should be to replace

@theme: red;

with

@theme: "red";

ie here:

@theme: "red";
.theme {
        color: ~"@{theme}";
}

@neonstalwart
Copy link
Contributor Author

thanks @Kalyse. your example is a little bit different but your suggestion is right.

@theme: "red";
~".@{theme}" {
  color: red;
}

gives me what i was expecting. thanks.

@vectorjohn
Copy link

This is still a bug. The syntax suggested by Kalyse won't work with nested rules using the & combinator.
E.g.:

@color: "red"

.something {
  ~( "&.color-@{color}" )
}

This inserts a literal & into my selector. Every other possible location for the & is a syntax error.

I can do exactly what I want if my variable value happens to not be one of the colors by leaving the quotes off of the variable value, i.e. @color: myred. Is there some reason I shouldn't be able to do that?

@vectorjohn
Copy link

Nevermind, it looks like what I really found was Issue #864

@lukeapage
Copy link
Member

Yes... Do this..

@a: ~"red";
&@{a} {
}

Should work in 1.3.1

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

No branches or pull requests

4 participants