Allow nested recursion in mixin calls (ala bootstrap)

This commit is contained in:
robotis
2012-06-04 07:38:06 +00:00
parent 78e32011c7
commit c8ae080be4
4 changed files with 75 additions and 4 deletions

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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;}

View File

@@ -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);