haml-edge 2.1.19 → 2.1.20
Sign up to get free protection for your applications and to get access to all the features.
- data/EDGE_GEM_VERSION +1 -1
- data/VERSION +1 -1
- data/lib/haml/precompiler.rb +9 -20
- data/test/haml/engine_test.rb +7 -0
- metadata +1 -1
data/EDGE_GEM_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.20
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.20
|
data/lib/haml/precompiler.rb
CHANGED
@@ -83,7 +83,7 @@ module Haml
|
|
83
83
|
DOCTYPE_REGEX = /(\d\.\d)?[\s]*([a-z]*)/i
|
84
84
|
|
85
85
|
# The Regex that matches a literal string or symbol value
|
86
|
-
LITERAL_VALUE_REGEX =
|
86
|
+
LITERAL_VALUE_REGEX = /:(\w*)|(["'])([^\\#'"]|\\.)*\2/
|
87
87
|
|
88
88
|
private
|
89
89
|
|
@@ -453,29 +453,18 @@ END
|
|
453
453
|
attributes
|
454
454
|
end
|
455
455
|
|
456
|
-
def parse_literal_value(text)
|
457
|
-
return nil unless text
|
458
|
-
text.match(LITERAL_VALUE_REGEX)
|
459
|
-
|
460
|
-
# $2 holds the value matched by a symbol, but is nil for a string match
|
461
|
-
# $5 holds the value matched by a string
|
462
|
-
$2 || $5
|
463
|
-
end
|
464
|
-
|
465
456
|
def parse_static_hash(text)
|
466
457
|
return {} unless text
|
467
458
|
|
468
459
|
attributes = {}
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
attributes[key] = value
|
460
|
+
scanner = StringScanner.new(text)
|
461
|
+
scanner.scan(/\s+/)
|
462
|
+
until scanner.eos?
|
463
|
+
return unless key = scanner.scan(LITERAL_VALUE_REGEX)
|
464
|
+
return unless scanner.scan(/\s*=>\s*/)
|
465
|
+
return unless value = scanner.scan(LITERAL_VALUE_REGEX)
|
466
|
+
attributes[eval(key).to_s] = eval(value).to_s
|
467
|
+
scanner.scan(/[,\s]*/)
|
479
468
|
end
|
480
469
|
text.count("\n").times { newline }
|
481
470
|
attributes
|
data/test/haml/engine_test.rb
CHANGED
@@ -756,6 +756,13 @@ END
|
|
756
756
|
assert_raise(Haml::Error, "Invalid output format :html1") { engine("%br", :format => :html1) }
|
757
757
|
end
|
758
758
|
|
759
|
+
def test_static_hashes
|
760
|
+
assert_equal("<a b='a => b'></a>\n", render("%a{:b => 'a => b'}", :suppress_eval => true))
|
761
|
+
assert_equal("<a b='a, b'></a>\n", render("%a{:b => 'a, b'}", :suppress_eval => true))
|
762
|
+
assert_equal("<a b='a\tb'></a>\n", render('%a{:b => "a\tb"}', :suppress_eval => true))
|
763
|
+
assert_equal("<a b='a\#{foo}b'></a>\n", render('%a{:b => "a\\#{foo}b"}', :suppress_eval => true))
|
764
|
+
end
|
765
|
+
|
759
766
|
# HTML 4.0
|
760
767
|
|
761
768
|
def test_html_has_no_self_closing_tags
|