Fix some operator output in to_sass.

This commit is contained in:
Chris Eppstein 2010-01-28 09:43:27 -08:00
parent b9af766886
commit 6b4290472c

View File

@ -54,7 +54,7 @@ module Sass
class CommentNode < Node class CommentNode < Node
def to_sass def to_sass
comment = silent ? "//" : "/*" comment = silent ? "//" : "/*"
comment << value comment << " " << value
lines.each do |line| lines.each do |line|
comment << " " << line comment << " " << line
end end
@ -204,20 +204,20 @@ module Sass
class Operation < Node class Operation < Node
unless defined? OPERATORS_TO_SASS unless defined? OPERATORS_TO_SASS
OPERATORS_TO_SASS = { OPERATORS_TO_SASS = {
:plus => '+', :plus => ' + ',
:minus => '-', :minus => ' - ',
:div => '/', :div => ' / ',
:mult => '*', :times => ' * ',
:comma => ',', :comma => ', ',
:concat => ' ', :concat => ' ',
:neq => '!=', :neq => ' ! =',
:eq => '==', :eq => ' == ',
:or => 'or', :or => ' or ',
:and => 'and' :and => ' and '
} }
end end
def to_sass(format = :text) def to_sass(format = :text)
"#{operand_to_sass(@operand1, format)} #{OPERATORS_TO_SASS[@operator]} #{operand_to_sass(@operand2, format)}" "#{operand_to_sass(@operand1, format)}#{OPERATORS_TO_SASS[@operator]}#{operand_to_sass(@operand2, format)}"
end end
def operand_to_sass(operand, format = :text) def operand_to_sass(operand, format = :text)
if operand.is_a? Operation if operand.is_a? Operation
@ -233,8 +233,13 @@ module Sass
end end
end end
class UnaryOperation < Node class UnaryOperation < Node
OPERATORS_TO_SASS = {
:minus => "-",
:div => "/",
:not => "not "
}
def to_sass(format = :text) def to_sass(format = :text)
"#{@operator}#{@operand}" "#{OPERATORS_TO_SASS[@operator]}#{@operand.to_sass}"
end end
end end
class Variable < Node class Variable < Node