Add a not operator (~) for Sass booleans.

This commit is contained in:
Nathan Weizenbaum 2008-08-09 10:37:29 -04:00
parent 901e1f378d
commit c2b34ff492
3 changed files with 15 additions and 0 deletions

View File

@ -30,6 +30,7 @@ module Sass
?* => :times,
?/ => :div,
?% => :mod,
?~ => :not,
?& => :single_and,
?| => :single_or,
CONSTANT_CHAR => :const,

View File

@ -53,6 +53,10 @@ class Sass::Constant::Literal # :nodoc:
to_bool ? self : other
end
def unary_not
Sass::Constant::Bool.from_value(!to_bool)
end
def concat(other)
Sass::Constant::String.from_value("#{self.to_s} #{other.to_s}")
end

View File

@ -396,6 +396,16 @@ a
f2 = false && true
f3 = true && false
f4 = false && false
SASS
assert_equal(<<CSS, render(<<SASS))
a {
b: true;
c: false; }
CSS
!var = true
a
b = ~~!var
c = ~!var
SASS
end