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

Variable redefinition more like php, js, etc #905

Closed
nathanielks opened this issue Aug 16, 2012 · 5 comments
Closed

Variable redefinition more like php, js, etc #905

nathanielks opened this issue Aug 16, 2012 · 5 comments

Comments

@nathanielks
Copy link

Here's the problem:

When I define a variable, then redefine it later, LESS's compiler seems to use the latter variable definition as opposed to using the first until it's been redefined.

Here's an example:

Style.less
-> import variables.less
-> Import base.less
-> import theme.less
-> import phone.less

If I define @Variable1 in variables.less, then redefine it in phone.less, LESS uses phone.less's @Variable1 definition across the entire project, instead of using it as it's been defined in variables.less until its been redefined in phone.less

Here's a real world scenario:
Style.less
-> import variables.less : set @font-size: 16;
-> Import base.less: body{ font-size: @font-size_1px; }
-> import theme.less
-> import phone.less, set @font-size: 12; body{ font-size: @font-size_1px; }

In both base.less and phone.less, body's font size will be 12px, and not 16 and 12 respectively. Anyway we can rework this, or do I have to use different variables?

@dmcass
Copy link
Contributor

dmcass commented Aug 16, 2012

Looks like this might be a duplicate of #297 perhaps?

@nathanielks
Copy link
Author

Hmm, I just read that and it seems we're having the opposite problems? They're saying that their variables are being redefined (which is what I want), but in my case they're not... Let me go back and look at my project and see if I'm doing something wrong.

@nathanielks
Copy link
Author

Ok, so this is weird. Here's the code I used lesso to test:

@red: #D14728;

#test1{
color: @red;
}

@red: #444;

#test2{
color: @red;
}

I used Lesso to test and it produces this output:

/* downloaded from http://www.below.ch/lesso/parse/23c8990f/1 */

#test1 { color:#d14728; }
#test2 { color:#444444; }

But when I use CodeKit to compile my less, it returns this:

#test1{color:#444444;}
#test2{color:#444444;}

And then when I use less.js, it gives me the same output. For one, I think lesso is possibly using a different Less compiler. Either way, any thoughts?

@nathanielks
Copy link
Author

From #297, lesso is using a different compiler

@lukeapage
Copy link
Member

just to be clear, is this issue this one

#297 (comment)

?

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

3 participants