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

[Sass] Make sure warnings for : use unquoted strings where possible.

This commit is contained in:
Nathan Weizenbaum 2010-03-29 18:00:18 -07:00
parent 2a2b2a987d
commit a1c1154aaa
5 changed files with 31 additions and 10 deletions

View file

@ -414,7 +414,7 @@ WARNING
if eq.strip[0] == SCRIPT_CHAR
expr.context = :equals
Script.equals_warning("properties", name, value, @line,
Script.equals_warning("properties", name, expr, @line,
line.offset + 1, @options[:filename])
end
end
@ -436,7 +436,7 @@ WARNING
expr.context = :equals
warning_name = "$#{name}"
warning_name << " ||" if op =~ /^\|\|/
Script.equals_warning("variables", warning_name, value,
Script.equals_warning("variables", warning_name, expr,
@line, line.offset + 1, @options[:filename])
end

View file

@ -53,7 +53,7 @@ MESSAGE
DEPRECATION WARNING:
On line #{line}#{", character #{offset}" if offset}#{" of '#{filename}'" if filename}
Setting #{types} with = has been deprecated and will be removed in version 3.2.
Use "#{name}: #{val}" instead.
Use "#{name}: #{val.to_sass}" instead.
MESSAGE
end
end

View file

@ -241,12 +241,11 @@ RUBY
return unless c = try_tok(:const)
var = Script::Variable.new(c.value)
if tok = (try_tok(:colon) || try_tok(:single_eq))
val = nil
val_str = @lexer.str {val = assert_expr(:concat)}
val = assert_expr(:concat)
if tok.type == :single_eq
val.context = :equals
Script.equals_warning("mixin argument defaults", "$#{c.value}", val_str.strip,
Script.equals_warning("mixin argument defaults", "$#{c.value}", val,
line, offset, @options[:filename])
end
elsif must_have_default

View file

@ -777,6 +777,13 @@ SCSS
assert_sass_to_scss '$var ||: 12px $bar baz;', '$var ||= 12px $bar "baz"'
end
# Sass 3 Deprecation conversions
def test_simple_quoted_strings_unquoted_with_equals
assert_sass_to_scss '$var: 1px foo + bar baz;', '!var = 1px "foo" + "bar" baz'
assert_sass_to_scss '$var: -foo-bar;', '!var = "-foo-bar"'
end
private
def assert_sass_to_sass(sass, options = {})

View file

@ -783,6 +783,21 @@ foo
SASS
end
def test_equals_warning_for_property_with_string
assert_warning(<<WARN) {assert_equal(<<CSS, render(<<SASS))}
DEPRECATION WARNING:
On line 2, character 3 of 'test_equals_warning_for_property_with_string_inline.sass'
Setting properties with = has been deprecated and will be removed in version 3.2.
Use "a: foo" instead.
WARN
foo {
a: foo; }
CSS
foo
a = "foo"
SASS
end
def test_guarded_assign
assert_equal("foo {\n a: b; }\n", render(%Q{$foo: b\n$foo ||: c\nfoo\n a: $foo}))
assert_equal("foo {\n a: b; }\n", render(%Q{$foo ||: b\nfoo\n a: $foo}))