diff options
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/javascript_helper.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb index a2f2577636..85b205c264 100644 --- a/actionpack/lib/action_view/helpers/javascript_helper.rb +++ b/actionpack/lib/action_view/helpers/javascript_helper.rb @@ -172,14 +172,17 @@ module ActionView # alert('All is good') # <% end -%> def javascript_tag(content_or_options_with_block = nil, html_options = {}, &block) - if block_given? - html_options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash) - content = capture(&block) - else - content = content_or_options_with_block - end + content = + if block_given? + html_options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash) + capture(&block) + else + content_or_options_with_block + end + + tag = content_tag("script", javascript_cdata_section(content), html_options.merge(:type => Mime::JS)) - concat(content_tag("script", javascript_cdata_section(content), html_options.merge(:type => Mime::JS))) + block_given? ? concat(tag) : tag end def javascript_cdata_section(content) #:nodoc: |