diff --git a/lesscpy/plib/deferred.py b/lesscpy/plib/deferred.py index e20658b..c8a9145 100644 --- a/lesscpy/plib/deferred.py +++ b/lesscpy/plib/deferred.py @@ -29,12 +29,16 @@ class Deferred(Node): returns: mixed """ + args = [p.parse(scope) + if hasattr(p, 'parse') + else p + for p in self.args] if hasattr(self.mixin, 'call'): - return self.mixin.call(scope, self.args) + return self.mixin.call(scope, args) mixins = scope.mixins(self.mixin.raw()) if not mixins: return mixins for mixin in mixins: - res = mixin.call(scope, self.args) + res = mixin.call(scope, args) if res: return res return False diff --git a/lesscpy/plib/expression.py b/lesscpy/plib/expression.py index 12f549e..e144cfb 100644 --- a/lesscpy/plib/expression.py +++ b/lesscpy/plib/expression.py @@ -77,7 +77,7 @@ class Expression(Node): returns: str """ - if not val: return val + if not val: return str(val) if ua or ub: if ua and ub: if ua == ub: @@ -88,7 +88,7 @@ class Expression(Node): return str(val) + ua elif ub: return str(val) + ub - return val + return str(val) def operate(self, vala, valb, oper): """Perform operation diff --git a/lesscpy/plib/string.py b/lesscpy/plib/string.py index b106753..5c25fa0 100644 --- a/lesscpy/plib/string.py +++ b/lesscpy/plib/string.py @@ -33,7 +33,7 @@ class String(Node): returns: str """ - var = '@' + var - var = ''.join(utility.flatten(self.scope.swap(var))) + var = self.scope.swap('@' + var) + var = ''.join(utility.flatten(var)) return var.strip("\"'") \ No newline at end of file diff --git a/lesscpy/test/testexpression.py b/lesscpy/test/testexpression.py index 12b0e9f..46566bc 100644 --- a/lesscpy/test/testexpression.py +++ b/lesscpy/test/testexpression.py @@ -6,14 +6,14 @@ from lesscpy.plib.expression import Expression class TestExpression(unittest.TestCase): def test_basic(self): for test in [ - ['0', '+', '0', 0], - ['2', '+', '2', 4], - ['2.0', '+', '2', 4.0], - ['2', '+', '2.0', 4.0], - ['2.0', '+', '2.0', 4.0], - [('2.0',), '+', '2.0', 4.0], - [('2.0',), '+', ('2.0',), 4.0], - ['0px', '+', '0', 0], + ['0', '+', '0', '0'], + ['2', '+', '2', '4'], + ['2.0', '+', '2', '4.0'], + ['2', '+', '2.0', '4.0'], + ['2.0', '+', '2.0', '4.0'], + [('2.0',), '+', '2.0', '4.0'], + [('2.0',), '+', ('2.0',), '4.0'], + ['0px', '+', '0', '0'], ['2px', '+', '2', '4px'], ['2.0px', '+', '2', '4.0px'], [('2px', ' '), '+', '2.0', '4.0px'], @@ -24,17 +24,17 @@ class TestExpression(unittest.TestCase): def test_neg(self): for test in [ - ['-0', '+', '0', 0], - ['-2', '+', '-2', -4], - ['-2.0', '+', '-2', -4.0], - ['-2', '+', '-2.0', -4.0], - ['-2.0', '+', '-2.0', -4.0], - ['-0', '-', '0', 0], - ['-2', '-', '-2', 0], - ['-2.0', '-', '2', -4.0], - ['-2', '-', '-2.0', 0], - ['2.0', '-', '-2.0', 4.0], - ['-0px', '+', '0', 0], + ['-0', '+', '0', '0'], + ['-2', '+', '-2', '-4'], + ['-2.0', '+', '-2', '-4.0'], + ['-2', '+', '-2.0', '-4.0'], + ['-2.0', '+', '-2.0', '-4.0'], + ['-0', '-', '0', '0'], + ['-2', '-', '-2', '0'], + ['-2.0', '-', '2', '-4.0'], + ['-2', '-', '-2.0', '0.0'], + ['2.0', '-', '-2.0', '4.0'], + ['-0px', '+', '0', '0'], ['-2px', '+', '-2', '-4px'], ['-2.0', '+', '-2px', '-4.0px'], ['-2em', '+', '-2.0', '-4.0em'],