Allow nested recursion in mixin calls (ala bootstrap)
This commit is contained in:
@@ -45,9 +45,6 @@ class Deferred(Node):
|
||||
ident.parse(scope)
|
||||
mixins = scope.mixins(ident.raw())
|
||||
|
||||
# if scope.real:
|
||||
# print(scope.real[-1].raw())
|
||||
|
||||
if not mixins:
|
||||
ident.parse(None)
|
||||
mixins = scope.mixins(ident.raw())
|
||||
@@ -78,6 +75,7 @@ class Deferred(Node):
|
||||
|
||||
if mixins:
|
||||
for mixin in mixins:
|
||||
scope.current = scope.real[-1] if scope.real else None
|
||||
res = mixin.call(scope, args)
|
||||
if res:
|
||||
# Add variables to scope to support
|
||||
|
||||
@@ -34,3 +34,36 @@
|
||||
.a .span1 {
|
||||
width: 12px;
|
||||
}
|
||||
.span3 {
|
||||
width: 60px;
|
||||
}
|
||||
.span2 {
|
||||
width: 36px;
|
||||
}
|
||||
.span1 {
|
||||
width: 12px;
|
||||
}
|
||||
.nested {
|
||||
padding: 1px;
|
||||
}
|
||||
.nested .span3 {
|
||||
width: 60px;
|
||||
}
|
||||
.nested .span2 {
|
||||
width: 36px;
|
||||
}
|
||||
.nested .span1 {
|
||||
width: 12px;
|
||||
}
|
||||
.nested .deep {
|
||||
padding: 1px;
|
||||
}
|
||||
.nested .deep .span3 {
|
||||
width: 60px;
|
||||
}
|
||||
.nested .deep .span2 {
|
||||
width: 36px;
|
||||
}
|
||||
.nested .deep .span1 {
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
11
lesscpy/test/css/mixin-args-recursive.min.css
vendored
11
lesscpy/test/css/mixin-args-recursive.min.css
vendored
@@ -10,3 +10,14 @@
|
||||
.a .span3{width:60px;}
|
||||
.a .span2{width:36px;}
|
||||
.a .span1{width:12px;}
|
||||
.span3{width:60px;}
|
||||
.span2{width:36px;}
|
||||
.span1{width:12px;}
|
||||
.nested{padding:1px;}
|
||||
.nested .span3{width:60px;}
|
||||
.nested .span2{width:36px;}
|
||||
.nested .span1{width:12px;}
|
||||
.nested .deep{padding:1px;}
|
||||
.nested .deep .span3{width:60px;}
|
||||
.nested .deep .span2{width:36px;}
|
||||
.nested .deep .span1{width:12px;}
|
||||
|
||||
@@ -12,4 +12,33 @@
|
||||
|
||||
.a {
|
||||
.spanX(12);
|
||||
}
|
||||
}
|
||||
// Nested recursion
|
||||
@gridColumns: 3;
|
||||
@gridColumnWidth: 60px;
|
||||
@gridGutterWidth: 20px;
|
||||
#grid {
|
||||
.core (@gridColumnWidth, @gridGutterWidth) {
|
||||
.spanX (@index) when (@index > 0) {
|
||||
(~".span@{index}") { .span(@index); }
|
||||
.spanX(@index - 1);
|
||||
}
|
||||
.spanX (0) {}
|
||||
|
||||
.span (@columns) {
|
||||
width: (@gridColumnWidth * @columns) + (@gridGutterWidth * (@columns - 1));
|
||||
}
|
||||
|
||||
.spanX (@gridColumns);
|
||||
|
||||
.nested {
|
||||
padding: 1px;
|
||||
.spanX (@gridColumns);
|
||||
.deep {
|
||||
padding: 1px;
|
||||
.spanX (@gridColumns);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#grid > .core(@gridColumnWidth, @gridGutterWidth);
|
||||
Reference in New Issue
Block a user