summaryrefslogtreecommitdiff
path: root/scss/ast.py
diff options
context:
space:
mode:
authorEevee (Alex Munroe) <eevee.git@veekun.com>2014-09-08 18:07:28 -0700
committerEevee (Alex Munroe) <eevee.git@veekun.com>2014-09-08 18:07:28 -0700
commite9e25b7de9cbf329abadd0f65b3d5a2b484f74b0 (patch)
tree1d23b3158537df964de67092070ddab00d1cb9b8 /scss/ast.py
parentecbd1f02e4c7a44dbfc2900f6eb3ddb41d60ae35 (diff)
downloadpyscss-e9e25b7de9cbf329abadd0f65b3d5a2b484f74b0.tar.gz
Allow arbitrary expressions for alpha(opacity=...).
Diffstat (limited to 'scss/ast.py')
-rw-r--r--scss/ast.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/scss/ast.py b/scss/ast.py
index 80d9b34..90cf76a 100644
--- a/scss/ast.py
+++ b/scss/ast.py
@@ -507,3 +507,20 @@ class FunctionLiteral(Expression):
contents = child.render()
quotes = None
return Function(contents, self.function_name, quotes=quotes)
+
+
+class AlphaFunctionLiteral(Expression):
+ """Wraps an existing AST node in a literal (unevaluated) function call,
+ prepending "opacity=" to the contents.
+ """
+ def __init__(self, child):
+ self.child = child
+
+ def evaluate(self, calculator, divide=False):
+ child = self.child.evaluate(calculator, divide)
+ if isinstance(child, String):
+ contents = child.value
+ else:
+ # TODO compress
+ contents = child.render()
+ return Function('opacity=' + contents, 'alpha', quotes=None)