summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEevee (Alex Munroe) <eevee.git@veekun.com>2014-08-28 17:30:52 -0700
committerEevee (Alex Munroe) <eevee.git@veekun.com>2014-09-01 21:30:57 -0700
commit3e73cf11f11a69731fc14ace34c7e99614964698 (patch)
tree1ebd2ae6a4e4be3031b0fb94ffbac4d194eea844
parent19354d99bc8def2358c41354c2b5f61f5c9925bd (diff)
downloadpyscss-3e73cf11f11a69731fc14ace34c7e99614964698.tar.gz
Fix assignment.
-rw-r--r--scss/blockast.py20
-rw-r--r--scss/compiler.py3
2 files changed, 19 insertions, 4 deletions
diff --git a/scss/blockast.py b/scss/blockast.py
index 153f7aa..f7ae857 100644
--- a/scss/blockast.py
+++ b/scss/blockast.py
@@ -37,9 +37,25 @@ class Declaration(Node):
pass
class Assignment(Declaration):
- def __init__(self, name, value):
+ def __init__(self, name, value_expression):
self.name = name
- self.value = value
+ self.value_expression = value_expression
+
+ @classmethod
+ def parse(cls, name, value):
+ # TODO pull off !default, !global
+ # TODO interp-parse the name
+
+ # TODO this is a bit naughty, but uses no state except the ast_cache --
+ # which should maybe be in the Compiler anyway...?
+ value_expression = Calculator().parse_expression(value)
+
+ return cls(name, value_expression)
+
+ def evaluate(self, compilation):
+ value = self.value_expression.evaluate(compilation.current_calculator)
+ compilation.current_namespace.set_variable(self.name, value)
+
class CSSDeclaration(Declaration):
def __init__(self, prop, value_expression):
diff --git a/scss/compiler.py b/scss/compiler.py
index ab1c4ba..c8de900 100644
--- a/scss/compiler.py
+++ b/scss/compiler.py
@@ -483,8 +483,7 @@ class Compilation(object):
return ScopeBlock(scope, unscoped_value)
elif name.startswith('$'):
# Sass variable assignment
- # TODO parse value, pull off !default and !global
- return Assignment(name, value)
+ return Assignment.parse(name, value)
else:
# Regular old CSS property declaration
return CSSDeclaration.parse(name, value)