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

[Sass] [sass-convert] Properly convert escaped backslashes in SassScript strings as well.

This commit is contained in:
Nathan Weizenbaum 2010-02-21 18:00:50 -08:00
parent d9e42478ff
commit 731891b5c3
2 changed files with 6 additions and 0 deletions

View file

@ -11,6 +11,8 @@ module Sass::Script
# @see Node#to_sass
def to_sass
# Replace single backslashes with double. Really.
value = self.value.gsub("\\", "\\\\\\\\")
return "\"#{value}\"" unless value.include?('"')
return "'#{value}'" unless value.include?("'")
"\"#{value.gsub('"', "\\\"")}\"" #'

View file

@ -39,6 +39,10 @@ class SassScriptConversionTest < Test::Unit::TestCase
assert_equal '"quote\'quote\\"quote"', render("'quote\\'quote\"quote'")
end
def test_string_escapes
assert_renders '"foo\\\\bar"'
end
def test_funcall
assert_renders "foo(true, blue)"
assert_renders "hsla(20deg, 30%, 50%, 0.3)"