Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 12th, 2012  |  syntax: None  |  size: 0.41 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How do import a Javascript file into a Haml view?
  2. !!!
  3. %html
  4.   %head
  5.     = javascript_include_tag "my_js_file"
  6.        
  7. !!!
  8. %html
  9.   %head
  10.     = yield(:javascripts)
  11.        
  12. - content_for :javascripts do
  13.   = javascript_include_tag "my_js_file"
  14.        
  15. :javascript
  16.   $(function() { alert("js inside haml"); }
  17.        
  18. = javascript_include_tag 'somefile'
  19.        
  20. config.assets.precompile += ['somefile.js']
  21.        
  22. :javascript
  23.   alert('hi hi!')