method
javascript_tag
v4.1.8 -
Show latest stable
-
0 notes -
Class: ActionView::Helpers::JavaScriptHelper
- 1.0.0 (0)
- 1.1.6 (0)
- 1.2.6 (38)
- 2.0.3 (34)
- 2.1.0 (0)
- 2.2.1 (0)
- 2.3.8 (0)
- 3.0.0 (0)
- 3.0.9 (-4)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (-8)
- 4.1.8 (0)
- 4.2.1 (5)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (33)
- 6.0.0 (1)
- 6.1.3.1 (7)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- 7.2.3 (0)
- 8.0.0 (0)
- 8.1.1 (0)
- What's this?
javascript_tag(content_or_options_with_block = nil, html_options = {}, &block)
public
Returns a JavaScript tag with the content inside. Example:
javascript_tag "alert('All is good')"
Returns:
<script> //<![CDATA[ alert('All is good') //]]> </script>
html_options may be a hash of attributes for the <script> tag.
javascript_tag "alert('All is good')", defer: 'defer' # => <script defer="defer">alert('All is good')</script>
Instead of passing the content as an argument, you can also use a block in which case, you pass your html_options as the first parameter.
<%= javascript_tag defer: 'defer' do -%> alert('All is good') <% end -%>

