From d9f27b263fe8e707d53afe6af25676e91e0dd455 Mon Sep 17 00:00:00 2001 From: nex3 Date: Sun, 10 Dec 2006 21:56:05 +0000 Subject: [PATCH] Fix for quote character bug (1.5dev) git-svn-id: svn://hamptoncatlin.com/haml/branches/1.5dev@206 7063305b-7217-0410-af8c-cdc13e5119b9 --- lib/haml/buffer.rb | 7 ++++++- test/haml/engine_test.rb | 3 ++- test/haml/results/just_stuff.xhtml | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/haml/buffer.rb b/lib/haml/buffer.rb index 724df01c..ed23a237 100644 --- a/lib/haml/buffer.rb +++ b/lib/haml/buffer.rb @@ -23,6 +23,7 @@ module Haml def initialize(options = {}) @options = options @quote_escape = options[:attr_wrapper] == '"' ? """ : "'" + @other_quote_char = options[:attr_wrapper] == '"' ? "'" : '"' @buffer = "" @one_liner_pending = false @tabulation = 0 @@ -172,7 +173,11 @@ module Haml v = v.to_s attr_wrapper = @options[:attr_wrapper] if v.include? attr_wrapper - v = v.gsub(attr_wrapper, @quote_escape) + if v.include? @other_quote_char + v = v.gsub(attr_wrapper, @quote_escape) + else + attr_wrapper = @other_quote_char + end end " #{a}=#{attr_wrapper}#{v}#{attr_wrapper}" end diff --git a/test/haml/engine_test.rb b/test/haml/engine_test.rb index fb4cf87d..638c0a46 100644 --- a/test/haml/engine_test.rb +++ b/test/haml/engine_test.rb @@ -61,7 +61,8 @@ class EngineTest < Test::Unit::TestCase def test_attr_wrapper assert_equal("

\n

\n", render("%p{ :strange => 'attrs'}", :attr_wrapper => '*')) - assert_equal("

\n

\n", render("%p{ :escaped => 'quo\"te'}", :attr_wrapper => '"')) + assert_equal("

\n

\n", render("%p{ :escaped => 'quo\"te'}", :attr_wrapper => '"')) + assert_equal("

\n

\n", render("%p{ :escaped => 'q\\'uo\"te'}", :attr_wrapper => '"')) assert_equal("\n", render("!!! XML", :attr_wrapper => '"')) end diff --git a/test/haml/results/just_stuff.xhtml b/test/haml/results/just_stuff.xhtml index 7e458470..67e18277 100644 --- a/test/haml/results/just_stuff.xhtml +++ b/test/haml/results/just_stuff.xhtml @@ -6,7 +6,7 @@ -Boo! +Boo!
wow!

Escape