Class: TurboBoost::Elements::TagBuilders::BaseTagBuilder
- Inherits:
-
Object
- Object
- TurboBoost::Elements::TagBuilders::BaseTagBuilder
- Defined in:
- lib/turbo_boost/elements/tag_builders/base_tag_builder.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#controller_pack ⇒ Object
readonly
Returns the value of attribute controller_pack.
Instance Method Summary collapse
-
#initialize(view_context) ⇒ BaseTagBuilder
constructor
A new instance of BaseTagBuilder.
- #render_tag(name, loading: :eager, **kwargs, &block) ⇒ Object
- #view_stack ⇒ Object
Constructor Details
#initialize(view_context) ⇒ BaseTagBuilder
Returns a new instance of BaseTagBuilder.
6 7 8 9 |
# File 'lib/turbo_boost/elements/tag_builders/base_tag_builder.rb', line 6 def initialize(view_context) @view_context = view_context @controller_pack = view_context.turbo_boost # TurboBoost::Commands::ControllerPack end |
Instance Attribute Details
#controller_pack ⇒ Object (readonly)
Returns the value of attribute controller_pack.
4 5 6 |
# File 'lib/turbo_boost/elements/tag_builders/base_tag_builder.rb', line 4 def controller_pack @controller_pack end |
Instance Method Details
#render_tag(name, loading: :eager, **kwargs, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/turbo_boost/elements/tag_builders/base_tag_builder.rb', line 11 def render_tag(name, loading: :eager, **kwargs, &block) = kwargs.select { |_, value| value.present? } .transform_keys! { |key| key.to_s.dasherize } loading = :eager unless loading == :lazy if loading == :eager view_context.tag.public_send(name.to_sym, **, &block) else view_context.tag.public_send(name.to_sym, **) {} end end |
#view_stack ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/turbo_boost/elements/tag_builders/base_tag_builder.rb', line 23 def view_stack prefix = "app/views/" locations = caller_locations.select { |location| location.path.include?(prefix) } locations.each_with_object(Set.new) do |location, memo| memo << location.path[(location.path.index(prefix) + prefix.length)..] end end |