diff options
Diffstat (limited to 'actionpack/lib/action_view/helpers/javascript_helper.rb')
-rw-r--r-- | actionpack/lib/action_view/helpers/javascript_helper.rb | 7 |
1 files changed, 5 insertions, 2 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: |