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
rubocop:enable Metrics/AbcSize.
- #pack_path(name, type: nil, manifest: nil) ⇒ Object
-
#render(options = {}, *locals, &block) ⇒ Object
rubocop:disable Metrics/AbcSize.
- #stylesheet_pack_tag(*names, **options) ⇒ Object
Instance Method Details
#image_pack_tag(name, **options) ⇒ Object
61 62 63 64 65 |
# File 'lib/frails/helper.rb', line 61 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
rubocop:enable Metrics/AbcSize
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/frails/helper.rb', line 31 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
67 68 69 |
# File 'lib/frails/helper.rb', line 67 def pack_path(name, type: nil, manifest: nil) manifest_manager[manifest].lookup! name, type: type end |
#render(options = {}, *locals, &block) ⇒ Object
rubocop:disable Metrics/AbcSize
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/frails/helper.rb', line 5 def render( = {}, *locals, &block) sload_assets = respond_to?(:side_load_assets?) ? side_load_assets? : false case when Hash in_rendering_context() do return view_renderer.render_component(self, , &block) if .key?(:component) [:side_load_assets] = sload_assets if block_given? view_renderer.render_partial(self, .merge(partial: [:layout]), &block) else view_renderer.render(self, ) end end else if .is_a?(Class) && < Frails::Component::Base return view_renderer.render_component(self, { component: , locals: locals }, &block) end view_renderer.render_partial(self, side_load_assets: sload_assets, partial: , locals: locals., &block) end end |
#stylesheet_pack_tag(*names, **options) ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/frails/helper.rb', line 50 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 |