2012-03-30 19:32:11 +00:00
|
|
|
# -*- coding: utf8 -*-
|
2012-03-18 14:21:58 +00:00
|
|
|
"""
|
2012-03-30 19:32:11 +00:00
|
|
|
.. module:: lesscpy.plib.deferred
|
|
|
|
:synopsis: Deferred mixin call.
|
|
|
|
|
|
|
|
Copyright (c)
|
|
|
|
See LICENSE for details.
|
|
|
|
.. moduleauthor:: Jóhann T. Maríusson <jtm@robot.is>
|
2012-03-18 14:21:58 +00:00
|
|
|
"""
|
|
|
|
from .node import Node
|
|
|
|
|
|
|
|
class Deferred(Node):
|
|
|
|
def __init__(self, mixin, args):
|
2012-03-30 19:32:11 +00:00
|
|
|
"""This node represents mixin calls
|
|
|
|
within the body of other mixins. The calls
|
|
|
|
to these mixins are deferred until the parent
|
|
|
|
mixin is called.
|
|
|
|
args:
|
|
|
|
mixin (Mixin): Mixin object
|
|
|
|
args (list): Call arguments
|
2012-03-18 14:21:58 +00:00
|
|
|
"""
|
|
|
|
self.mixin = mixin
|
|
|
|
self.args = args
|
|
|
|
|
|
|
|
def parse(self, scope):
|
2012-03-30 19:32:11 +00:00
|
|
|
""" Parse function.
|
|
|
|
args:
|
|
|
|
scope (Scope): Scope object
|
|
|
|
returns:
|
|
|
|
mixed
|
2012-03-18 14:21:58 +00:00
|
|
|
"""
|
|
|
|
if hasattr(self.mixin, 'call'):
|
|
|
|
return self.mixin.call(scope, self.args)
|
2012-03-24 18:33:19 +00:00
|
|
|
mixins = scope.mixins(self.mixin.raw())
|
|
|
|
if not mixins: return mixins
|
2012-03-30 19:32:11 +00:00
|
|
|
for mixin in mixins:
|
|
|
|
res = mixin.call(scope, self.args)
|
|
|
|
if res:
|
|
|
|
return res
|
|
|
|
return False
|
|
|
|
|