Skip to content

Commit f945fa6

Browse files
committed
Update detached-rulesets.md
1 parent f5a194d commit f945fa6

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

content/features/detached-rulesets.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,40 @@ which will output
9292
}
9393
```
9494

95+
Detached ruleset call unlocks (returns) all its mixins into caller the same way as mixin calls do. However, it does NOT return variables.
96+
97+
Returned mixin:
98+
````less
99+
// detached ruleset with a mixin
100+
@detached-ruleset: {
101+
.mixin() {
102+
color:blue;
103+
}
104+
};
105+
// call detached ruleset
106+
.caller {
107+
@detached-ruleset();
108+
.mixin();
109+
}
110+
````
111+
112+
Results in:
113+
````css
114+
.caller {
115+
color: blue;
116+
}
117+
````
118+
119+
Private variables:
120+
````less
121+
detached-ruleset: {
122+
@color:blue; //this variable is private
123+
};
124+
.caller {
125+
color: @color; //syntax error
126+
}
127+
````
128+
95129
## Scoping
96130
Detached ruleset can use all variables and mixins accessible on place where it is *defined* and where it is *called*. Otherwise said, both definition and caller scopes are available to it. If both scopes contains the same variable or mixin, declaration scope value takes precedence.
97131

0 commit comments

Comments
 (0)