Module: Stimulus::ImportmapHelper
- Defined in:
- lib/stimulus/importmap_helper.rb
Instance Method Summary collapse
Instance Method Details
#importmap_list_from(*paths) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/stimulus/importmap_helper.rb', line 6 def importmap_list_from(*paths) Array(paths).flat_map do |path| absolute_path = Rails.root.join(path) dirname = absolute_path.basename.to_s absolute_path.children.collect do |module_filename| module_name = importmap_module_name_from(module_filename) %("#{module_name}": "#{asset_path("#{dirname}/#{module_filename.basename}")}") end end.join(",\n") end |
#importmap_list_with_stimulus_from(*paths) ⇒ Object
2 3 4 |
# File 'lib/stimulus/importmap_helper.rb', line 2 def importmap_list_with_stimulus_from(*paths) [ %("stimulus": "#{asset_path("stimulus/libraries/stimulus")}"), importmap_list_from(*paths) ].join(",\n") end |