2014-07-22 20:14:57 -04:00
|
|
|
module DeferredScriptsHelper
|
2014-07-22 19:46:43 -04:00
|
|
|
|
|
|
|
# Provides a javascript map of the files in the 'defer' directory
|
2014-07-22 20:14:57 -04:00
|
|
|
def deferred_scripts
|
2014-07-22 19:46:43 -04:00
|
|
|
files = {}
|
|
|
|
|
|
|
|
Dir.glob("#{Rails.root}/app/assets/javascripts/defer/*.js").each do |file|
|
|
|
|
module_name = "defer/#{File.basename(file, '.js')}"
|
|
|
|
file_name = asset_path("defer/#{File.basename(file)}")
|
|
|
|
files[module_name] = file_name
|
|
|
|
end
|
|
|
|
|
|
|
|
return files.to_json.html_safe
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|