Module: Simpacker::Helper
- Defined in:
- lib/simpacker/helper.rb
Instance Method Summary collapse
- #asset_pack_path(name, **options) ⇒ Object
- #asset_pack_url(name, **options) ⇒ Object
- #favicon_pack_tag(name, **options) ⇒ Object
- #image_pack_tag(name, **options) ⇒ Object
- #image_pack_url(name, **options) ⇒ Object
- #javascript_pack_tag(*names, **options) ⇒ Object
- #picture_pack_tag(*names, &block) ⇒ Object
- #simpacker_context ⇒ Object
- #stylesheet_pack_tag(*names, **options) ⇒ Object
Instance Method Details
#asset_pack_path(name, **options) ⇒ Object
17 18 19 |
# File 'lib/simpacker/helper.rb', line 17 def asset_pack_path(name, **) asset_path(simpacker_context.manifest.lookup!(name), **) end |
#asset_pack_url(name, **options) ⇒ Object
21 22 23 |
# File 'lib/simpacker/helper.rb', line 21 def asset_pack_url(name, **) asset_url(simpacker_context.manifest.lookup!(name), **) end |
#favicon_pack_tag(name, **options) ⇒ Object
43 44 45 |
# File 'lib/simpacker/helper.rb', line 43 def favicon_pack_tag(name, **) favicon_link_tag(asset_path(simpacker_context.manifest.lookup!(name)), **) end |
#image_pack_tag(name, **options) ⇒ Object
25 26 27 |
# File 'lib/simpacker/helper.rb', line 25 def image_pack_tag(name, **) image_tag(asset_path(simpacker_context.manifest.lookup!(name)), **) end |
#image_pack_url(name, **options) ⇒ Object
29 30 31 |
# File 'lib/simpacker/helper.rb', line 29 def image_pack_url(name, **) asset_url(simpacker_context.manifest.lookup!(name), **) end |
#javascript_pack_tag(*names, **options) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/simpacker/helper.rb', line 3 def javascript_pack_tag(*names, **) sources = names.map do |name| simpacker_context.manifest.lookup!("#{name}#{compute_asset_extname(name.to_s, type: :javascript)}") end javascript_include_tag(*sources, **) end |
#picture_pack_tag(*names, &block) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/simpacker/helper.rb', line 33 def picture_pack_tag(*names, &block) unless Rails.gem_version >= Gem::Version.new('7.1.0') raise NotImplementedError, '`picture_pack_tag` is only available for Rails 7.1 or above.' end names.flatten! = names. sources = names.map { |name| asset_path(simpacker_context.manifest.lookup!(name)) } picture_tag(*sources, , &block) end |
#simpacker_context ⇒ Object
47 48 49 |
# File 'lib/simpacker/helper.rb', line 47 def simpacker_context Simpacker.default_context end |
#stylesheet_pack_tag(*names, **options) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/simpacker/helper.rb', line 10 def stylesheet_pack_tag(*names, **) sources = names.map do |name| simpacker_context.manifest.lookup!("#{name}#{compute_asset_extname(name.to_s, type: :stylesheet)}") end stylesheet_link_tag(*sources, **) end |