Skip to content

Instantly share code, notes, and snippets.

@dewski
Created April 16, 2010 01:01
Show Gist options
  • Save dewski/367864 to your computer and use it in GitHub Desktop.
Save dewski/367864 to your computer and use it in GitHub Desktop.
def juicer_script_tag(file)
if Rails.env == 'development'
contents = File.read(File.expand_path("#{file}.js", File.join(Rails.root, 'public', 'javascripts')))
files = []
contents.scan(/\@depends?\s+([^\s\'\"\;]+)/).to_a.each do |included|
files << included.first unless included.first =~ /\*/
end
# The file that was to be included should be last.
files << file.to_s
else
files = "#{file}.min"
end
javascript_include_tag(files)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment