]> git.openstreetmap.org Git - rails.git/blob - app/helpers/asset_helper.rb
Cache social link platform and name at save time (#6950)
[rails.git] / app / helpers / asset_helper.rb
1 # frozen_string_literal: true
2
3 module AssetHelper
4   def assets(directory)
5     asset_list = Rails.application.assets_manifest.assets.keys
6     if asset_list.empty?
7       # when assets are not precompiled
8       env = Rails.application.assets
9       env.each_file do |path|
10         asset_list << env[path]&.logical_path if path.include?(directory)
11       end
12     end
13     asset_list.each_with_object({}) do |asset, assets|
14       assets[asset] = asset_path(asset) if asset&.start_with?("#{directory}/")
15     end
16   end
17 end