From 863d8a0acb806f32e0db52153b1a51045880e043 Mon Sep 17 00:00:00 2001 From: "Eevee (Alex Munroe)" Date: Tue, 13 Aug 2013 13:42:45 -0700 Subject: Restore string * number multiplication. --- scss/types.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scss/types.py b/scss/types.py index f3e3b9d..cb0d90f 100644 --- a/scss/types.py +++ b/scss/types.py @@ -736,6 +736,17 @@ class String(Value): self.value + other_value, quotes='"' if self.quotes else None) + def __mul__(self, other): + # DEVIATION: Ruby Sass doesn't do this, because Ruby doesn't. But + # Python does, and in Ruby Sass it's just fatal anyway. + if not isinstance(other, Number): + return super(String, self).__mul__(other) + + if not other.is_unitless: + raise TypeError("Can only multiply strings by unitless numbers") + + return String(self.value * other.value, quotes=self.quotes) + def render(self, compress=False): return self.__str__() -- cgit v1.2.1