mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 18:54:13 +08:00
21 lines
508 B
Ruby
21 lines
508 B
Ruby
|
module DeferredJavascriptsHelper
|
||
|
|
||
|
# Provides a javascript map of the files in the 'defer' directory
|
||
|
def deferred_javascripts
|
||
|
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
|
||
|
|
||
|
module Sprockets::Rails::Helper
|
||
|
include DeferredJavascriptsHelper
|
||
|
end
|