diff --git a/lib/haml/parser.rb b/lib/haml/parser.rb index c5b339ba75..d0b23cf19d 100644 --- a/lib/haml/parser.rb +++ b/lib/haml/parser.rb @@ -202,7 +202,7 @@ def initialize(*args) end def inspect - %Q[(#{type} #{value.inspect}#{children.each_with_object('') {|c, s| s << "\n#{c.inspect.gsub!(/^/, ' ')}"}})] + %Q[(#{type} #{value.inspect}#{children.each_with_object(''.dup) {|c, s| s << "\n#{c.inspect.gsub!(/^/, ' ')}"}})].dup end end diff --git a/test/parser_test.rb b/test/parser_test.rb index 1a62490d10..972aa1f2b4 100644 --- a/test/parser_test.rb +++ b/test/parser_test.rb @@ -96,6 +96,15 @@ class ParserTest < Haml::TestCase end end + test "inspect for node with children returns text" do + text = "some revealed text" + cond = "[cond]" + + node = parse("/!#{cond} #{text}") + + assert_equal "(root nil\n (comment {:conditional=>\"[cond]\", :text=>\"some revealed text\", :revealed=>true, :parse=>false}))", node.inspect + end + test "revealed conditional comments are detected" do text = "some revealed text" cond = "[cond]"