public
Description: HTML Abstraction Markup Language - A Markup Haiku
Homepage: http://haml.hamptoncatlin.com
Clone URL: git://github.com/nex3/haml.git
Fix for quote bug (1.0rc).


git-svn-id: svn://hamptoncatlin.com/haml/branches/1.0rc@205 
7063305b-7217-0410-af8c-cdc13e5119b9
nex3 (author)
Sun Dec 10 13:46:06 -0800 2006
commit  ab9c210dacb60234ea22f8462b88526b5d75ee6f
tree    eea38410329b935b0c19a6549be4539e58f4d63d
parent  72315473a337bd362c480a58e839a6cb75382637
...
23
24
25
 
26
27
28
...
172
173
174
175
 
 
 
 
 
176
177
178
...
23
24
25
26
27
28
29
...
173
174
175
 
176
177
178
179
180
181
182
183
0
@@ -23,6 +23,7 @@ module Haml
0
     def initialize(options = {})
0
       @options = options
0
       @quote_escape = options[:attr_wrapper] == '"' ? """ : "'"
0
+ @other_quote_char = options[:attr_wrapper] == '"' ? "'" : '"'
0
       @buffer = ""
0
       @one_liner_pending = false
0
       @tabulation = 0
0
@@ -172,7 +173,11 @@ module Haml
0
           v = v.to_s
0
           attr_wrapper = @options[:attr_wrapper]
0
           if v.include? attr_wrapper
0
- v = v.gsub(attr_wrapper, @quote_escape)
0
+ if v.include? @other_quote_char
0
+ v = v.gsub(attr_wrapper, @quote_escape)
0
+ else
0
+ attr_wrapper = @other_quote_char
0
+ end
0
           end
0
           " #{a}=#{attr_wrapper}#{v}#{attr_wrapper}"
0
         end
...
60
61
62
63
 
 
64
65
66
...
60
61
62
 
63
64
65
66
67
0
@@ -60,7 +60,8 @@ class EngineTest < Test::Unit::TestCase
0
 
0
   def test_attr_wrapper
0
     assert_equal("<p strange=*attrs*>\n</p>\n", render("%p{ :strange => 'attrs'}", :attr_wrapper => '*'))
0
- assert_equal("<p escaped=\"quo&quot;te\">\n</p>\n", render("%p{ :escaped => 'quo\"te'}", :attr_wrapper => '"'))
0
+ assert_equal("<p escaped='quo\"te'>\n</p>\n", render("%p{ :escaped => 'quo\"te'}", :attr_wrapper => '"'))
0
+ assert_equal("<p escaped=\"q'uo&quot;te\">\n</p>\n", render("%p{ :escaped => 'q\\'uo\"te'}", :attr_wrapper => '"'))
0
     assert_equal("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n", render("!!! XML", :attr_wrapper => '"'))
0
   end
0
 

Comments

    No one has commented yet.