diff --git a/lib/haml/engine.rb b/lib/haml/engine.rb index aec5ba13..d786175b 100644 --- a/lib/haml/engine.rb +++ b/lib/haml/engine.rb @@ -100,7 +100,7 @@ module Haml TAG_REGEX = /[%]([-:\w]+)([-\w\.\#]*)(\{.*\})?(\[.*\])?([=\/\~]?)?(.*)?/ # The Regex that matches a literal string or symbol value - LITERAL_VALUE_REGEX = /^\s*(:(\w*)|(('|")([^\\\#]*?)\4))\s*$/ + LITERAL_VALUE_REGEX = /^\s*(:(\w*)|(('|")([^\\\#'"]*?)\4))\s*$/ # Creates a new instace of Haml::Engine that will compile the given # template string when render is called. diff --git a/test/haml/engine_test.rb b/test/haml/engine_test.rb index 0891022d..cb308943 100644 --- a/test/haml/engine_test.rb +++ b/test/haml/engine_test.rb @@ -141,6 +141,11 @@ class EngineTest < Test::Unit::TestCase assert_equal("NOT RECOMPILED\n", render(template, :locals => { :text => "first time" })) assert_equal("

first time

\n", render(template, :locals => { :text => "first time", :foo => 'bar' })) end + + def test_dynamc_attrs_shouldnt_register_as_literal_values + assert_equal("

\n

\n", render('%p{:a => "b#{1 + 1}c"}')) + assert_equal("

\n

\n", render("%p{:a => 'b' + (1 + 1).to_s + 'c'}")) + end def test_comps assert_equal(-1, "foo" <=> nil)