Module: Frails::Helper
- Defined in:
- lib/frails/helper.rb
Instance Method Summary collapse
- #image_pack_tag(name, **options) ⇒ Object
- #javascript_pack_tag(*names, **options) ⇒ Object
- #pack_path(name, type: nil, manifest: nil) ⇒ Object
- #render(options = {}, locals = {}, &block) ⇒ Object
- #stylesheet_pack_tag(*names, **options) ⇒ Object
Instance Method Details
#image_pack_tag(name, **options) ⇒ Object
56 57 58 59 60 |
# File 'lib/frails/helper.rb', line 56 def image_pack_tag(name, **) return if Rails.env.test? image_tag(pack_path("images/#{name}", manifest: .delete(:manifest)), **) end |
#javascript_pack_tag(*names, **options) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/frails/helper.rb', line 26 def javascript_pack_tag(*names, **) return if Rails.env.test? @included_javascripts ||= [] soft_lookup = .delete(:soft_lookup) { false } sources = sources_from_manifest_entries(names, :javascript, manifest: .delete(:manifest), soft_lookup: soft_lookup) # Make sure that we don't include an asset that has already been included. sources -= @included_javascripts sources.compact! # Concatenate the sources to be included to those already included. @included_javascripts.concat sources sources.empty? ? nil : javascript_include_tag(*sources, **) end |
#pack_path(name, type: nil, manifest: nil) ⇒ Object
62 63 64 |
# File 'lib/frails/helper.rb', line 62 def pack_path(name, type: nil, manifest: nil) manifest_manager[manifest].lookup! name, type: type end |
#render(options = {}, locals = {}, &block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/frails/helper.rb', line 4 def render( = {}, locals = {}, &block) sload_assets = respond_to?(:side_load_assets?) ? side_load_assets? : false case when Hash in_rendering_context() do [:side_load_assets] = sload_assets return view_renderer.render_component(self, , &block) if .key?(:component) if block_given? view_renderer.render_partial(self, .merge(partial: [:layout]), &block) else view_renderer.render(self, ) end end else view_renderer.render_partial(self, side_load_assets: sload_assets, partial: , locals: locals, &block) end end |
#stylesheet_pack_tag(*names, **options) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/frails/helper.rb', line 45 def stylesheet_pack_tag(*names, **) return if Rails.env.test? soft_lookup = .delete(:soft_lookup) { false } sources = sources_from_manifest_entries(names, :stylesheet, manifest: .delete(:manifest), soft_lookup: soft_lookup) sources.compact! stylesheet_link_tag(*sources, **) end |