diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index ca9197ba8b..89c834dd47 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fixed all helpers so that they use XHTML compliant double quotes for values instead of single quotes [htonl/bitsweat]
+
* Added link_to_image(src, options = {}, html_options = {}, *parameters_for_method_reference). Documentation:
Creates a link tag to the image residing at the +src+ using an URL created by the set of +options+. See the valid options in
diff --git a/actionpack/lib/action_view/helpers/active_record_helper.rb b/actionpack/lib/action_view/helpers/active_record_helper.rb
index eee8b6b970..4f7d66d8f7 100644
--- a/actionpack/lib/action_view/helpers/active_record_helper.rb
+++ b/actionpack/lib/action_view/helpers/active_record_helper.rb
@@ -52,12 +52,13 @@ module ActionView
def form(record_name, options = {})
record = instance_eval("@#{record_name}")
action = url_for(:action => options[:action] || (record.new_record? ? "create" : "update"))
+ submit_value = options[:submit_value] || action.gsub(/[^\w]/, '').capitalize
+
id_field = record.new_record? ? "" : InstanceTag.new(record_name, "id", self).to_input_field_tag("hidden")
-
- "
"
+
+ %()
end
# Returns a string containing the error message attached to the +method+ on the +object+, if one exists.
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index 5526c3eef4..8af3afb034 100755
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -143,8 +143,8 @@ module ActionView
end
month_options << ((date.kind_of?(Fixnum) ? date : date.month) == month_number ?
- "#{month_name} \n" :
- "#{month_name} \n"
+ %(#{month_name} \n) :
+ %(#{month_name} \n)
)
end
@@ -172,9 +172,9 @@ module ActionView
private
def select_html(type, options, prefix = nil, include_blank = false, discard_type = false)
- select_html = "\n"
+ select_html << %(">\n)
select_html << " \n" if include_blank
select_html << options.to_s
select_html << " \n"
diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb
index 13aa9297ca..6139943567 100644
--- a/actionpack/lib/action_view/helpers/tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/tag_helper.rb
@@ -10,7 +10,7 @@ module ActionView
# * tag("br") =>
# * tag("input", { "type" => "text"}) =>
def tag(name, options = {}, open = false)
- "<#{name + tag_options(options)}" + (open ? ">" : " />")
+ "<#{name}#{tag_options(options)}" + (open ? ">" : " />")
end
# Examples:
@@ -18,7 +18,7 @@ module ActionView
# * content_tag("div", content_tag("p", "Hello world!"), "class" => "strong") =>
#
def content_tag(name, content, options = {})
- "<#{name + tag_options(options)}>#{content}#{name}>"
+ "<#{name}#{tag_options(options)}>#{content}#{name}>"
end
# Starts a form tag that points the action to an url configured with url_for_options just like
@@ -46,12 +46,10 @@ module ActionView
private
def tag_options(options)
- if options.empty?
- ""
- else
- " " + options.collect { |pair|
- "#{pair.first}=\"#{html_escape(pair.last)}\""
- }.sort.join(" ")
+ unless options.empty?
+ " " + options.map { |key, value|
+ %(#{key}="#{html_escape(value)}")
+ }.sort.join(" ")
end
end
end
diff --git a/actionpack/test/template/active_record_helper_test.rb b/actionpack/test/template/active_record_helper_test.rb
index 9cc0f58d0a..5bae7ee6b5 100644
--- a/actionpack/test/template/active_record_helper_test.rb
+++ b/actionpack/test/template/active_record_helper_test.rb
@@ -51,27 +51,27 @@ class ActiveRecordHelperTest < Test::Unit::TestCase
def test_generic_input_tag
assert_equal(
- ' ', input("post", "title")
+ %( ), input("post", "title")
)
end
def test_text_area_with_errors
assert_equal(
- "
",
+ %(
),
text_area("post", "body")
)
end
def test_text_field_with_errors
assert_equal(
- '
',
+ %(
),
text_field("post", "author_name")
)
end
def test_form_with_string
assert_equal(
- "",
+ %(Title
\nBody
Back to the hill and over it again!
),
form("post")
)
end
@@ -80,7 +80,7 @@ class ActiveRecordHelperTest < Test::Unit::TestCase
def Post.content_columns() [ Column.new(:date, "written_on", "Written on") ] end
assert_equal(
- "Written on \n1999 \n2000 \n2001 \n2002 \n2003 \n2004 \n2005 \n2006 \n2007 \n2008 \n2009 \n \n\nJanuary \nFebruary \nMarch \nApril \nMay \nJune \nJuly \nAugust \nSeptember \nOctober \nNovember \nDecember \n \n\n1 \n2 \n3 \n4 \n5 \n6 \n7 \n8 \n9 \n10 \n11 \n12 \n13 \n14 \n15 \n16 \n17 \n18 \n19 \n20 \n21 \n22 \n23 \n24 \n25 \n26 \n27 \n28 \n29 \n30 \n31 \n \n
",
+ %(Written on \n1999 \n2000 \n2001 \n2002 \n2003 \n2004 \n2005 \n2006 \n2007 \n2008 \n2009 \n \n\nJanuary \nFebruary \nMarch \nApril \nMay \nJune \nJuly \nAugust \nSeptember \nOctober \nNovember \nDecember \n \n\n1 \n2 \n3 \n4 \n5 \n6 \n7 \n8 \n9 \n10 \n11 \n12 \n13 \n14 \n15 \n16 \n17 \n18 \n19 \n20 \n21 \n22 \n23 \n24 \n25 \n26 \n27 \n28 \n29 \n30 \n31 \n \n
),
form("post")
)
end
@@ -90,13 +90,13 @@ class ActiveRecordHelperTest < Test::Unit::TestCase
@post.written_on = Time.gm(2004, 6, 15, 16, 30)
assert_equal(
- "Written on \n1999 \n2000 \n2001 \n2002 \n2003 \n2004 \n2005 \n2006 \n2007 \n2008 \n2009 \n \n\nJanuary \nFebruary \nMarch \nApril \nMay \nJune \nJuly \nAugust \nSeptember \nOctober \nNovember \nDecember \n \n\n1 \n2 \n3 \n4 \n5 \n6 \n7 \n8 \n9 \n10 \n11 \n12 \n13 \n14 \n15 \n16 \n17 \n18 \n19 \n20 \n21 \n22 \n23 \n24 \n25 \n26 \n27 \n28 \n29 \n30 \n31 \n \n — \n00 \n01 \n02 \n03 \n04 \n05 \n06 \n07 \n08 \n09 \n10 \n11 \n12 \n13 \n14 \n15 \n16 \n17 \n18 \n19 \n20 \n21 \n22 \n23 \n \n : \n00 \n01 \n02 \n03 \n04 \n05 \n06 \n07 \n08 \n09 \n10 \n11 \n12 \n13 \n14 \n15 \n16 \n17 \n18 \n19 \n20 \n21 \n22 \n23 \n24 \n25 \n26 \n27 \n28 \n29 \n30 \n31 \n32 \n33 \n34 \n35 \n36 \n37 \n38 \n39 \n40 \n41 \n42 \n43 \n44 \n45 \n46 \n47 \n48 \n49 \n50 \n51 \n52 \n53 \n54 \n55 \n56 \n57 \n58 \n59 \n \n
",
+ %(Written on \n1999 \n2000 \n2001 \n2002 \n2003 \n2004 \n2005 \n2006 \n2007 \n2008 \n2009 \n \n\nJanuary \nFebruary \nMarch \nApril \nMay \nJune \nJuly \nAugust \nSeptember \nOctober \nNovember \nDecember \n \n\n1 \n2 \n3 \n4 \n5 \n6 \n7 \n8 \n9 \n10 \n11 \n12 \n13 \n14 \n15 \n16 \n17 \n18 \n19 \n20 \n21 \n22 \n23 \n24 \n25 \n26 \n27 \n28 \n29 \n30 \n31 \n \n — \n00 \n01 \n02 \n03 \n04 \n05 \n06 \n07 \n08 \n09 \n10 \n11 \n12 \n13 \n14 \n15 \n16 \n17 \n18 \n19 \n20 \n21 \n22 \n23 \n \n : \n00 \n01 \n02 \n03 \n04 \n05 \n06 \n07 \n08 \n09 \n10 \n11 \n12 \n13 \n14 \n15 \n16 \n17 \n18 \n19 \n20 \n21 \n22 \n23 \n24 \n25 \n26 \n27 \n28 \n29 \n30 \n31 \n32 \n33 \n34 \n35 \n36 \n37 \n38 \n39 \n40 \n41 \n42 \n43 \n44 \n45 \n46 \n47 \n48 \n49 \n50 \n51 \n52 \n53 \n54 \n55 \n56 \n57 \n58 \n59 \n \n
),
form("post")
)
end
def test_error_for_block
- assert_equal "1 error prohibited this post from being saved There were problems with the following fields:
Author name can't be empty ", error_messages_for("post")
- assert_equal "1 error prohibited this post from being saved There were problems with the following fields:
Author name can't be empty ", error_messages_for("post", :class => "errorDeathByClass", :id => "errorDeathById", :header_tag => "h1")
+ assert_equal %(1 error prohibited this post from being saved There were problems with the following fields:
Author name can't be empty ), error_messages_for("post")
+ assert_equal %(1 error prohibited this post from being saved There were problems with the following fields:
Author name can't be empty ), error_messages_for("post", :class => "errorDeathByClass", :id => "errorDeathById", :header_tag => "h1")
end
end
diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb
index a8ad37918d..5e9d79b26e 100755
--- a/actionpack/test/template/date_helper_test.rb
+++ b/actionpack/test/template/date_helper_test.rb
@@ -16,9 +16,9 @@ class DateHelperTest < Test::Unit::TestCase
end
def test_select_day
- expected = "\n"
+ expected = %(\n)
expected <<
-"1 \n2 \n3 \n4 \n5 \n6 \n7 \n8 \n9 \n10 \n11 \n12 \n13 \n14 \n15 \n16 \n17 \n18 \n19 \n20 \n21 \n22 \n23 \n24 \n25 \n26 \n27 \n28 \n29 \n30 \n31 \n"
+%(1 \n2 \n3 \n4 \n5 \n6 \n7 \n8 \n9 \n10 \n11 \n12 \n13 \n14 \n15 \n16 \n17 \n18 \n19 \n20 \n21 \n22 \n23 \n24 \n25 \n26 \n27 \n28 \n29 \n30 \n31 \n)
expected << " \n"
assert_equal expected, select_day(Time.mktime(2003, 8, 16))
@@ -26,9 +26,9 @@ class DateHelperTest < Test::Unit::TestCase
end
def test_select_day_with_blank
- expected = "\n"
+ expected = %(\n)
expected <<
-" \n1 \n2 \n3 \n4 \n5 \n6 \n7 \n8 \n9 \n10 \n11 \n12 \n13 \n14 \n15 \n16 \n17 \n18 \n19 \n20 \n21 \n22 \n23 \n24 \n25 \n26 \n27 \n28 \n29 \n30 \n31 \n"
+%( \n1 \n2 \n3 \n4 \n5 \n6 \n7 \n8 \n9 \n10 \n11 \n12 \n13 \n14 \n15 \n16 \n17 \n18 \n19 \n20 \n21 \n22 \n23 \n24 \n25 \n26 \n27 \n28 \n29 \n30 \n31 \n)
expected << " \n"
assert_equal expected, select_day(Time.mktime(2003, 8, 16), :include_blank => true)
@@ -36,8 +36,8 @@ class DateHelperTest < Test::Unit::TestCase
end
def test_select_month
- expected = "\n"
- expected << "January \nFebruary \nMarch \nApril \nMay \nJune \nJuly \nAugust \nSeptember \nOctober \nNovember \nDecember \n"
+ expected = %(\n)
+ expected << %(January \nFebruary \nMarch \nApril \nMay \nJune \nJuly \nAugust \nSeptember \nOctober \nNovember \nDecember \n)
expected << " \n"
assert_equal expected, select_month(Time.mktime(2003, 8, 16))
@@ -45,8 +45,8 @@ class DateHelperTest < Test::Unit::TestCase
end
def test_select_month_with_numbers
- expected = "\n"
- expected << "1 \n2 \n3 \n4 \n5 \n6 \n7 \n8 \n9 \n10 \n11 \n12 \n"
+ expected = %(\n)
+ expected << %(1 \n2 \n3 \n4 \n5 \n6 \n7 \n8 \n9 \n10 \n11 \n12 \n)
expected << " \n"
assert_equal expected, select_month(Time.mktime(2003, 8, 16), :use_month_numbers => true)
@@ -54,8 +54,8 @@ class DateHelperTest < Test::Unit::TestCase
end
def test_select_month_with_numbers_and_names
- expected = "\n"
- expected << "1 - January \n2 - February \n3 - March \n4 - April \n5 - May \n6 - June \n7 - July \n8 - August \n9 - September \n10 - October \n11 - November \n12 - December \n"
+ expected = %(\n)
+ expected << %(1 - January \n2 - February \n3 - March \n4 - April \n5 - May \n6 - June \n7 - July \n8 - August \n9 - September \n10 - October \n11 - November \n12 - December \n)
expected << " \n"
assert_equal expected, select_month(Time.mktime(2003, 8, 16), :add_month_numbers => true)
@@ -63,8 +63,8 @@ class DateHelperTest < Test::Unit::TestCase
end
def test_select_year
- expected = "\n"
- expected << "2003 \n2004 \n2005 \n"
+ expected = %(\n)
+ expected << %(2003 \n2004 \n2005 \n)
expected << " \n"
assert_equal expected, select_year(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005)
@@ -72,8 +72,8 @@ class DateHelperTest < Test::Unit::TestCase
end
def test_select_year_with_type_discarding
- expected = "\n"
- expected << "2003 \n2004 \n2005 \n"
+ expected = %(\n)
+ expected << %(2003 \n2004 \n2005 \n)
expected << " \n"
assert_equal expected, select_year(
@@ -84,17 +84,17 @@ class DateHelperTest < Test::Unit::TestCase
def test_select_date
- expected = "\n"
- expected << "2003 \n2004 \n2005 \n"
+ expected = %(\n)
+ expected << %(2003 \n2004 \n2005 \n)
expected << " \n"
- expected << "\n"
- expected << "January \nFebruary \nMarch \nApril \nMay \nJune \nJuly \nAugust \nSeptember \nOctober \nNovember \nDecember \n"
+ expected << %(\n)
+ expected << %(January \nFebruary \nMarch \nApril \nMay \nJune \nJuly \nAugust \nSeptember \nOctober \nNovember \nDecember \n)
expected << " \n"
- expected << "\n"
+ expected << %(\n)
expected <<
-"1 \n2 \n3 \n4 \n5 \n6 \n7 \n8 \n9 \n10 \n11 \n12 \n13 \n14 \n15 \n16 \n17 \n18 \n19 \n20 \n21 \n22 \n23 \n24 \n25 \n26 \n27 \n28 \n29 \n30 \n31 \n"
+%(1 \n2 \n3 \n4 \n5 \n6 \n7 \n8 \n9 \n10 \n11 \n12 \n13 \n14 \n15 \n16 \n17 \n18 \n19 \n20 \n21 \n22 \n23 \n24 \n25 \n26 \n27 \n28 \n29 \n30 \n31 \n)
expected << " \n"
assert_equal expected, select_date(