diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-06-12 17:48:30 -0500 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-06-12 17:48:30 -0500 |
commit | ea3a7e1bb1efc8b3ca10c4163bc116f3d5e23af1 (patch) | |
tree | a3cce25be0c613a8e1444e1d0ff53aaed3497057 /actionpack/lib/action_view/helpers/javascript_helper.rb | |
parent | 556204abaf95f7c995576cb1358f13de406682ab (diff) | |
parent | dd4181f47dc0f166eb5d3e47a4a0dc1594cc5669 (diff) | |
download | rails-ea3a7e1bb1efc8b3ca10c4163bc116f3d5e23af1.tar.gz rails-ea3a7e1bb1efc8b3ca10c4163bc116f3d5e23af1.tar.bz2 rails-ea3a7e1bb1efc8b3ca10c4163bc116f3d5e23af1.zip |
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'actionpack/lib/action_view/helpers/javascript_helper.rb')
-rw-r--r-- | actionpack/lib/action_view/helpers/javascript_helper.rb | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb index 1ea3cbd74e..7404a251e4 100644 --- a/actionpack/lib/action_view/helpers/javascript_helper.rb +++ b/actionpack/lib/action_view/helpers/javascript_helper.rb @@ -172,20 +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 - javascript_tag = content_tag("script", javascript_cdata_section(content), html_options.merge(:type => Mime::JS)) - - if block_given? && block_is_within_action_view?(block) - concat(javascript_tag, block.binding) - else - javascript_tag - end + tag = 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: @@ -205,11 +202,6 @@ module ActionView end js_option end - - private - def block_is_within_action_view?(block) - eval("defined? _erbout", block.binding) - end end JavascriptHelper = JavaScriptHelper unless const_defined? :JavascriptHelper |