diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/tag_helper.rb | 7 | ||||
-rw-r--r-- | actionpack/test/template/tag_helper_test.rb | 5 |
3 files changed, 13 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 631e328b03..2c1085738c 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed that content_tag with a block will just return the result instead of concate it if not used in a ERb view #7857, #7432 [michael.niessner] + * Replace the current block/continuation filter chain handling by an implementation based on a simple loop. #8226 [Stefan Kaes] * Update UrlWriter to accept :anchor parameter. Closes #6771. [octopod] diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb index 0e99cfab65..7c6903220a 100644 --- a/actionpack/lib/action_view/helpers/tag_helper.rb +++ b/actionpack/lib/action_view/helpers/tag_helper.rb @@ -48,7 +48,8 @@ module ActionView if block_given? options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash) content = capture(&block) - concat(content_tag_string(name, content, options), block.binding) + content_tag = content_tag_string(name, content, options) + block_is_within_action_view?(block) ? concat(content_tag, block.binding) : content_tag else content = content_or_options_with_block content_tag_string(name, content, options) @@ -98,6 +99,10 @@ module ActionView def fix_double_escape(escaped) escaped.gsub(/&([a-z]+|(#\d+));/i) { "&#{$1};" } end + + def block_is_within_action_view?(block) + eval("defined? _erbout", block.binding) + end end end end diff --git a/actionpack/test/template/tag_helper_test.rb b/actionpack/test/template/tag_helper_test.rb index 342c3843a1..b839d53f6b 100644 --- a/actionpack/test/template/tag_helper_test.rb +++ b/actionpack/test/template/tag_helper_test.rb @@ -47,6 +47,11 @@ class TagHelperTest < Test::Unit::TestCase assert_dom_equal %(<div class="green">Hello world!</div>), _erbout end + def test_content_tag_with_block_and_options_outside_of_action_view + assert_equal content_tag("a", "Create", :href => "create"), + content_tag("a", "href" => "create") { "Create" } + end + def test_cdata_section assert_equal "<![CDATA[<hello world>]]>", cdata_section("<hello world>") end |