less/less.js — pull request #2180 by SomMeri (2014-09-05 07:32:22+00:00)
Title: Added guards checking to namespaces. 

Related to issue #1418.

Pull request adds guards and parameters checks to namespaces:
* The `#namespace(@variable)` will not be used as namespace anymore.
* The `#namespace when (false_condition)` will not be used as namespace anymore.

````css
#namespace(@variable) { // mandatory parameter - can not be used as namespace
.mixin() { mandatory: parameter; }
}
@go: true;
#namespace(...) when (@go){ // ok
.mixin() { works: works; }
}
#namespace(@variable: default) when (@go){ // ok - parameter is optional
.mixin() { optional: optional; }
}
#namespace(...) when not(@go){ // false guard - can not be used as namespace
.mixin() { guard: false; }
}
.use {
#namespace > .mixin();
}
````

compiles into:
````
.use {
works: works;
optional: optional;
}
````

How the default() function works: the default function is assumed to have the same value for all matched namespaces.

Following two namespaced mixins are matched exactly the same way:
````
#sp_1() when (default()) {
.mixin() { /* */ }
}
#sp_1() {
.mixin() when (default()) { /* */ }
}
````

The mixin is never evaluated
````
#sp_1() when (default()) {
.mixin() when not(default()) { /* */ }
}
````