1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

[Sass] Never print unquote() to CSS with quoted strings in =.

This commit is contained in:
Nathan Weizenbaum 2010-05-04 13:39:40 -07:00
parent 9721c4e7f2
commit ac6357c69d
3 changed files with 23 additions and 19 deletions

View file

@ -3,6 +3,12 @@
* Table of contents
{:toc}
## 3.0.0.rc.5 (Unreleased)
* Fix a bug with quoted SassScript strings in `=`.
Not that `=` should be used anymore,
but we're trying to preserve backwards-compatibility.
## 3.0.0.rc.4
[Tagged on GitHub](http://github.com/nex3/haml/commit/3.0.0.rc.4).

View file

@ -41,23 +41,8 @@ module Sass::Script
# @see Node#to_s
def to_s(opts = {})
to_sass(opts)
end
# @param opts [{Symbol => Object}]
# `opts[:type]` -- The type of string to render this as.
# `:string`s have double quotes, `:identifier`s do not.
# Defaults to `:identifier`.
# @see Node#to_sass
def to_sass(opts = {})
type = opts[:type] || self.type
if type == :identifier
if context == :equals && self.value !~ Sass::SCSS::RX::URI &&
Sass::SCSS::RX.escape_ident(self.value).include?(?\\)
return "unquote(#{Sass::Script::String.new(self.value, :string).to_sass})"
elsif context == :equals && self.value.size == 0
return %q{""}
end
if self.type == :identifier
return %q{""} if context == :equals && self.value.size == 0
return self.value.gsub("\n", " ")
end
@ -67,5 +52,16 @@ module Sass::Script
return "'#{value}'" unless value.include?("'")
"\"#{value.gsub('"', "\\\"")}\"" #'
end
# @see Node#to_sass
def to_sass(opts = {})
if self.type == :identifier && context == :equals &&
self.value !~ Sass::SCSS::RX::URI &&
Sass::SCSS::RX.escape_ident(self.value).include?(?\\)
return "unquote(#{Sass::Script::String.new(self.value, :string).to_sass})"
else
return to_s
end
end
end
end

View file

@ -1608,13 +1608,15 @@ foo {
a: foo;
b: bar;
c: foo bar;
d: foo, bar; }
d: foo, bar baz;
e: foo bar, bar; }
CSS
foo
a= "foo"
b= bar
c= "foo" bar
d= foo, "bar"
d= foo, "bar baz"
e= "foo bar", bar
SASS
end
end