Compile all css files in a rails project


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. # compiles all the css files into one huge string
  2. # this is useful when running with less
  3. # USAGE : all_css.open # => opens the string in less allowing you to search
  4. def all_css
  5. css_files = Dir.glob File.join(RAILS_ROOT, "public/stylesheets/","*.css")
  6. css_content = ""
  7. css_files.each {|file| css_content << IO.read(file)}
  8.  
  9. css_content.instance_eval do
  10.  
  11. # opens with less command
  12. def open
  13. system('echo "' << self << '"|less')
  14. end
  15.  
  16. end
  17.  
  18. css_content
  19. end
  20.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.