javascript_tag(content, html_options = {}) public

Returns a JavaScript tag with the content inside. Example:

  javascript_tag "alert('All is good')"

Returns:

  <script type="text/javascript">
  //<![CDATA[
  alert('All is good')
  //]]>
  </script>

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>
Show source
Register or log in to add new notes.