You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
difference between a imported namespace and a declared one #1895
The problem is we process mixin calls before we process rulesets - so that mixins can bring variables into scope.
Although we process imports before mixin calls, we don't do that recursively.
To fix this we need to pull out the import process to a seperate visitor before the eval call. I think this would be a good idea.
@CMCDragonkai see #1848 for namespaced vars. to wrap a third party less file use #bootstrap {@import "../../components/bootstrap/dist/css/bootstrap-theme.css";}
update (for @CMCDragonkai) #bootstrap {@import (reference) "bootstrap.less";} compiled indeed all bootstrap's code into the CSS. Maybe this should be an other question. I'm not sure what to expect when referencing a namespace.
I.e. the problem there is not that .nsmixin is not visible inside .mixin itself but that it's invisible in the global scope (the scope where #ns is defined).
Alternatively it can be solved via:
@CMCDragonkai#bootstrap {@import (less) "..../bootstrap.css";} and #bootstrap {@import (less, reference) "..../bootstrap.css";} work since Less 1.5.0 (don't miss ; in the end of the import statement). See the docs.
Namespacing "bootstrap.less" is not recommended since it does not work properly that way, see #1826, #1709 etc.
It seems that this importing external files into namespaces only works when the original code is considered to be a "less" file.
However the file that I'm importing is just a CSS file. Furthermore I want to "(reference)" it. So is there a way to make less recognise that I want to reference it and process it as a less file?
@CMCDragonkai I've updated my answer with correct imports. Later on please use the SO for a general "usage/how-to" like stuff. It's quite difficult to track the issues in time when discussion there quickly spreads too wide.
@seven-phases-max Sorry for derailing the discussion. But @bassjobsen brought up an issue while doing it your way:
update (for @CMCDragonkai) #bootstrap {@import (reference) "bootstrap.less";} compiled indeed all bootstrap's code into the CSS. Maybe this should be an other question. I'm not sure what to expect when referencing a namespace.
I used your updated snippet. And yes it does work now, but "reference" does not actually reference properly, the entire CSS code in Bootstrap is imported into the output.
@CMCDragonkai OK, then I guess that's a good case for another ticket, i.e. @import (less, reference) "bootstrap.less"; works as expected but #bs {@import (less, reference) "bootstrap.less";} does not.
Activity
lukeapage commentedon Feb 23, 2014
The problem is we process mixin calls before we process rulesets - so that mixins can bring variables into scope.
Although we process imports before mixin calls, we don't do that recursively.
To fix this we need to pull out the import process to a seperate visitor before the eval call. I think this would be a good idea.
work-around would be to wrap everything in
&e.g.bassjobsen commentedon Feb 23, 2014
Thank for your quick response. I agrees it seems a good idea to fix this.
NB i don't understand how if have to wrap my namespace mixin in:
lukeapage commentedon Feb 23, 2014
Sorry.. what do you mean?
CMCDragonkai commentedon Feb 23, 2014
I've been looking for something like this.
I would like to namespace external third party code while also "referencing" them. This makes CSS closer to modular architecture similar to CommonJS.
Something like this:
This makes all the CSS code inside bootstrap-theme contained inside the #Namespace, while still abiding by the (reference) keyword.
A question, can variables be "namespaced"? They seem like they can't.
bassjobsen commentedon Feb 23, 2014
@lukeapage i try to find a fix for:
@CMCDragonkai see #1848 for namespaced vars. to wrap a third party less file use
#bootstrap {@import "../../components/bootstrap/dist/css/bootstrap-theme.css";}update (for @CMCDragonkai)
#bootstrap {@import (reference) "bootstrap.less";}compiled indeed all bootstrap's code into the CSS. Maybe this should be an other question. I'm not sure what to expect when referencing a namespace.seven-phases-max commentedon Feb 23, 2014
@bassjobsen
I.e. the problem there is not that
.nsmixinis not visible inside.mixinitself but that it's invisible in the global scope (the scope where#nsis defined).Alternatively it can be solved via:
CMCDragonkai commentedon Feb 23, 2014
@bassjobsen What do you mean? Neither this syntax
Nor what I suggested
Currently works? I get a syntax error.
seven-phases-max commentedon Feb 23, 2014
@CMCDragonkai
#bootstrap {@import (less) "..../bootstrap.css";}and#bootstrap {@import (less, reference) "..../bootstrap.css";}work since Less 1.5.0 (don't miss;in the end of the import statement). See the docs.Namespacing "bootstrap.less" is not recommended since it does not work properly that way, see #1826, #1709 etc.
bassjobsen commentedon Feb 23, 2014
@seven-phases-max, thanks that (the & for my mixin) works well
CMCDragonkai commentedon Feb 23, 2014
Hey @seven-phases-max
I used your snippet. And it works some what. There's an issue.
So this does not work (I get the undefined error):
However this does work:
It seems that this importing external files into namespaces only works when the original code is considered to be a "less" file.
However the file that I'm importing is just a CSS file. Furthermore I want to "(reference)" it. So is there a way to make less recognise that I want to reference it and process it as a less file?
seven-phases-max commentedon Feb 23, 2014
@CMCDragonkai I've updated my answer with correct imports. Later on please use the SO for a general "usage/how-to" like stuff. It's quite difficult to track the issues in time when discussion there quickly spreads too wide.
CMCDragonkai commentedon Feb 23, 2014
@seven-phases-max Sorry for derailing the discussion. But @bassjobsen brought up an issue while doing it your way:
I used your updated snippet. And yes it does work now, but "reference" does not actually reference properly, the entire CSS code in Bootstrap is imported into the output.
This indeed can be a separate question.
seven-phases-max commentedon Feb 23, 2014
@CMCDragonkai OK, then I guess that's a good case for another ticket, i.e.
@import (less, reference) "bootstrap.less";works as expected but#bs {@import (less, reference) "bootstrap.less";}does not.CMCDragonkai commentedon Feb 23, 2014
#1896