basic nested mixins
This commit is contained in:
@@ -366,7 +366,7 @@ class LessParser(object):
|
||||
mixin = self.scope.mixins(n)
|
||||
if mixin:
|
||||
try:
|
||||
p[0] = mixin.call(None)
|
||||
p[0] = mixin.call(None, self.scope)
|
||||
except SyntaxError as e:
|
||||
self.handle_error(e, p)
|
||||
p[0] = None
|
||||
@@ -383,7 +383,7 @@ class LessParser(object):
|
||||
p[0] = [b.parsed['proplist'] for b in l]
|
||||
elif mixin:
|
||||
try:
|
||||
p[0] = mixin.call(None)
|
||||
p[0] = mixin.call(None, self.scope)
|
||||
except SyntaxError as e:
|
||||
self.handle_error(e, p)
|
||||
p[0] = None
|
||||
|
||||
@@ -19,8 +19,9 @@ class Block(Process):
|
||||
"""
|
||||
self._blocktype = None
|
||||
self.scope = scope
|
||||
self._proplist()
|
||||
# self._proplist()
|
||||
self._pname()
|
||||
self._proplist()
|
||||
if self._name.startswith('@media'):
|
||||
self._blocktype = 'inner'
|
||||
self.parsed['identifier'] = self._ident.strip()
|
||||
@@ -75,7 +76,10 @@ class Block(Process):
|
||||
self.parsed['inner'] = []
|
||||
for p in utility.flatten(self._p[2]):
|
||||
if not p: continue
|
||||
if not p.parsed: p.parse(self.scope)
|
||||
if not p.parsed:
|
||||
if type(p) is type(self):
|
||||
self.scope.current = self._ident
|
||||
p.parse(self.scope)
|
||||
if type(p) is type(self):
|
||||
self.parsed['inner'].append(p)
|
||||
elif 'property' in p.parsed:
|
||||
|
||||
@@ -33,7 +33,7 @@ class Mixin(Process):
|
||||
else:
|
||||
self.argv = []
|
||||
self.argc = 0
|
||||
self.prop = self._p[2]
|
||||
self.nodes = self._p[2]
|
||||
|
||||
def call(self, args, scope=None):
|
||||
""" Call mixin function.
|
||||
@@ -46,12 +46,12 @@ class Mixin(Process):
|
||||
if p]
|
||||
self.scope = scope if scope else Scope(True)
|
||||
self.scope[0]['__variables__'].update(self.stash)
|
||||
prop = [copy.deepcopy(p) for p in self.prop if p]
|
||||
prop = utility.flatten([p.call(args, self.scope)
|
||||
if type(p) is Mixin else p
|
||||
for p in prop])
|
||||
nodes = [copy.deepcopy(p) for p in self.nodes if p]
|
||||
nodes = utility.flatten([p.call(args, self.scope)
|
||||
if type(p) is Mixin else p
|
||||
for p in nodes])
|
||||
self._process_args(args)
|
||||
return [p.parse(self.scope) for p in prop]
|
||||
return [p.parse(self.scope) for p in nodes]
|
||||
|
||||
def _process_args(self, args):
|
||||
""" Process arguments to mixin call.
|
||||
|
||||
18
lesscpy/test/css/mixins-nested-basic.css
Normal file
18
lesscpy/test/css/mixins-nested-basic.css
Normal file
@@ -0,0 +1,18 @@
|
||||
.content {
|
||||
width: 600px;
|
||||
}
|
||||
.content .column {
|
||||
margin: 600px;
|
||||
}
|
||||
.content .column.blue {
|
||||
color: blue;
|
||||
}
|
||||
.content-em {
|
||||
width: 200px;
|
||||
}
|
||||
.content-em .column {
|
||||
margin: 200px;
|
||||
}
|
||||
.content-em .column.blue {
|
||||
color: blue;
|
||||
}
|
||||
6
lesscpy/test/css/mixins-nested-basic.min.css
vendored
Normal file
6
lesscpy/test/css/mixins-nested-basic.min.css
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
.content{width:600px;}
|
||||
.content .column{margin:600px;}
|
||||
.content .column.blue{color:blue;}
|
||||
.content-em{width:200px;}
|
||||
.content-em .column{margin:200px;}
|
||||
.content-em .column.blue{color:blue;}
|
||||
15
lesscpy/test/less/mixins-nested-basic.less
Normal file
15
lesscpy/test/less/mixins-nested-basic.less
Normal file
@@ -0,0 +1,15 @@
|
||||
.nested-ruleset (@width: 200px) {
|
||||
width: @width;
|
||||
.column {
|
||||
margin: @width;
|
||||
&.blue {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
.content {
|
||||
.nested-ruleset(600px);
|
||||
}
|
||||
.content-em {
|
||||
.nested-ruleset();
|
||||
}
|
||||
Reference in New Issue
Block a user