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

Merge branch 'master' into rgba

This commit is contained in:
Nathan Weizenbaum 2009-11-10 23:01:29 -08:00
commit 6fb01eb885
3 changed files with 11 additions and 28 deletions

View file

@ -13,6 +13,13 @@ Sass now supports functions that return the values of the
and {Sass::Script::Functions#green green} and {Sass::Script::Functions#green green}
components of colors. components of colors.
### Variable Names
SassScript variable names may now contain hyphens.
For example:
!prettiest-color = #542FA9
### Error Backtraces ### Error Backtraces
Numerous bugs were fixed with the backtraces given for Sass errors, Numerous bugs were fixed with the backtraces given for Sass errors,

View file

@ -52,8 +52,8 @@ module Sass
# A hash of regular expressions that are used for tokenizing. # A hash of regular expressions that are used for tokenizing.
REGULAR_EXPRESSIONS = { REGULAR_EXPRESSIONS = {
:whitespace => /\s*/, :whitespace => /\s*/,
:variable => /!(\w+)/, :variable => /!([\w-]+)/,
:ident => /(\\.|\#\{|[^\s\\+\-*\/%(),=!])+/, :ident => /(\\.|\#\{|[^\s\\+*\/%(),=!])+/,
:string_end => /((?:\\.|\#[^{]|[^"\\#])*)(?:"|(?=#\{))/, :string_end => /((?:\\.|\#[^{]|[^"\\#])*)(?:"|(?=#\{))/,
:number => /(-)?(?:(\d*\.\d+)|(\d+))([a-zA-Z%]+)?/, :number => /(-)?(?:(\d*\.\d+)|(\d+))([a-zA-Z%]+)?/,
:color => /\##{"([0-9a-fA-F]{1,2})" * 3}|(#{Color::HTML4_COLORS.keys.join("|")})(?!\()/, :color => /\##{"([0-9a-fA-F]{1,2})" * 3}|(#{Color::HTML4_COLORS.keys.join("|")})(?!\()/,
@ -162,16 +162,6 @@ module Sass
def op def op
prev_chr = @scanner.string[@scanner.pos - 1].chr prev_chr = @scanner.string[@scanner.pos - 1].chr
return unless op = @scanner.scan(REGULAR_EXPRESSIONS[:op]) return unless op = @scanner.scan(REGULAR_EXPRESSIONS[:op])
if @prev && op == '-' && prev_chr !~ /\s/ &&
[:bool, :ident, :const].include?(@prev.type)
warn(<<END)
DEPRECATION WARNING:
On line #{@line}, character #{last_match_position}#{" of '#{@filename}'" if @filename}
- will be allowed as part of variable names in version 2.4.
Please add whitespace to separate it from the previous token.
END
end
[OPERATORS[op]] [OPERATORS[op]]
end end

View file

@ -140,22 +140,8 @@ WARN
assert_equal "public_instance_methods()", resolve("public_instance_methods()") assert_equal "public_instance_methods()", resolve("public_instance_methods()")
end end
def test_hyphen_warning def test_hyphenated_variables
a = Sass::Script::String.new("a") assert_equal("a-b", resolve("!a-b", {}, env("a-b" => Sass::Script::String.new("a-b"))))
b = Sass::Script::String.new("b")
assert_warning(<<WARN) {eval("!a-!b", {}, env("a" => a, "b" => b))}
DEPRECATION WARNING:
On line 1, character 3 of 'test_hyphen_warning_inline.sass'
- will be allowed as part of variable names in version 2.4.
Please add whitespace to separate it from the previous token.
WARN
assert_warning(<<WARN) {eval("true-false")}
DEPRECATION WARNING:
On line 1, character 5 of 'test_hyphen_warning_inline.sass'
- will be allowed as part of variable names in version 2.4.
Please add whitespace to separate it from the previous token.
WARN
end end
def test_ruby_equality def test_ruby_equality