mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Fix for quote character bug (1.5dev)
git-svn-id: svn://hamptoncatlin.com/haml/branches/1.5dev@206 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
parent
6914f275f3
commit
d9f27b263f
3 changed files with 9 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -61,7 +61,8 @@ class EngineTest < Test::Unit::TestCase
|
|||
|
||||
def test_attr_wrapper
|
||||
assert_equal("<p strange=*attrs*>\n</p>\n", render("%p{ :strange => 'attrs'}", :attr_wrapper => '*'))
|
||||
assert_equal("<p escaped=\"quo"te\">\n</p>\n", render("%p{ :escaped => 'quo\"te'}", :attr_wrapper => '"'))
|
||||
assert_equal("<p escaped='quo\"te'>\n</p>\n", render("%p{ :escaped => 'quo\"te'}", :attr_wrapper => '"'))
|
||||
assert_equal("<p escaped=\"q'uo"te\">\n</p>\n", render("%p{ :escaped => 'q\\'uo\"te'}", :attr_wrapper => '"'))
|
||||
assert_equal("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n", render("!!! XML", :attr_wrapper => '"'))
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
||||
<strong apos='Foo's bar!'>Boo!</strong>
|
||||
<strong apos="Foo's bar!">Boo!</strong>
|
||||
<div class='render'><em>wow!</em></div>
|
||||
<p>
|
||||
Escape
|
||||
|
|
Loading…
Add table
Reference in a new issue