diff --git a/lib/haml/parser.rb b/lib/haml/parser.rb
index 7270cd35..3309e130 100644
--- a/lib/haml/parser.rb
+++ b/lib/haml/parser.rb
@@ -83,8 +83,7 @@ module Haml
DOCTYPE_REGEX = /(\d(?:\.\d)?)?\s*([a-z]*)\s*([^ ]+)?/i
# The Regex that matches a literal string or symbol value
- LITERAL_VALUE_REGEX = /:(\w*)|(["'])((?![\\#]|\2).|\\.)*\2/
-
+ LITERAL_VALUE_REGEX = /:(\w*)|(["'])((?!\\|\#{|\#@|\#\$|\2).|\\.)*\2/
def initialize(template, options)
@options = options
diff --git a/test/engine_test.rb b/test/engine_test.rb
index 1ec207ff..2fbffdd0 100644
--- a/test/engine_test.rb
+++ b/test/engine_test.rb
@@ -1386,12 +1386,26 @@ HAML
assert_equal("\n", render("%a{:b => 'a, b'}", :suppress_eval => true))
assert_equal("\n", render('%a{:b => "a\tb"}', :suppress_eval => true))
assert_equal("\n", render('%a{:b => "a\\#{foo}b"}', :suppress_eval => true))
+ assert_equal("\n", render("%a{:b => '#f00'}", :suppress_eval => true))
end
def test_dynamic_hashes_with_suppress_eval
assert_equal("\n", render('%a{:b => "a #{1 + 1} b", :c => "d"}', :suppress_eval => true))
end
+ def test_interpolates_instance_vars_in_attribute_values
+ scope = Object.new
+ scope.instance_variable_set :@foo, 'bar'
+ assert_equal("\n", render('%a{:b => "a #@foo b"}', :scope => scope))
+ end
+
+ def test_interpolates_global_vars_in_attribute_values
+ # make sure the value isn't just interpolated in during template compilation
+ engine = Haml::Engine.new('%a{:b => "a #$global_var_for_testing b"}')
+ $global_var_for_testing = 'bar'
+ assert_equal("\n", engine.to_html)
+ end
+
def test_utf8_attrs
assert_equal("\n", render("%a{:href => 'héllo'}"))
assert_equal("\n", render("%a(href='héllo')"))