diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-10-09 00:50:11 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-10-09 00:50:11 +0000 |
commit | 8ff92e243568a6ae72e88f48a7ae15dffaf81e57 (patch) | |
tree | 5c2a0faa2d36a819733b71ca3f0a8565ac12a90e /actionpack/lib | |
parent | ca35e264a43790ec96306388cbe0a078a5c355eb (diff) | |
download | rails-8ff92e243568a6ae72e88f48a7ae15dffaf81e57.tar.gz rails-8ff92e243568a6ae72e88f48a7ae15dffaf81e57.tar.bz2 rails-8ff92e243568a6ae72e88f48a7ae15dffaf81e57.zip |
Added an html_options hash parameter to javascript_tag() and update_page_tag() helpers #6311 [tzaharia]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5245 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/javascript_helper.rb | 7 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/prototype_helper.rb | 7 |
2 files changed, 10 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb index 039a2f1810..7bce6b91eb 100644 --- a/actionpack/lib/action_view/helpers/javascript_helper.rb +++ b/actionpack/lib/action_view/helpers/javascript_helper.rb @@ -162,8 +162,11 @@ module ActionView # alert('All is good') # //]]> # </script> - def javascript_tag(content) - content_tag("script", javascript_cdata_section(content), :type => "text/javascript") + # + # +html_options+ may be a hash of attributes for the <script> tag. Example: + # javascript_tag "alert('All is good')", :defer => 'true' # => <script defer="true" type="text/javascript">alert('All is good')</script> + def javascript_tag(content, html_options = {}) + content_tag("script", javascript_cdata_section(content), html_options.merge(:type => "text/javascript")) end def javascript_cdata_section(content) #:nodoc: diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb index 60dc2e8bb4..f1b956cf12 100644 --- a/actionpack/lib/action_view/helpers/prototype_helper.rb +++ b/actionpack/lib/action_view/helpers/prototype_helper.rb @@ -684,8 +684,11 @@ module ActionView # Works like update_page but wraps the generated JavaScript in a <script> # tag. Use this to include generated JavaScript in an ERb template. # See JavaScriptGenerator for more information. - def update_page_tag(&block) - javascript_tag update_page(&block) + # + # +html_options+ may be a hash of <script> attributes to be passed + # to ActionView::Helpers::JavaScriptHelper#javascript_tag. + def update_page_tag(html_options = {}, &block) + javascript_tag update_page(&block), html_options end protected |