Class: Vident::ViewComponent::RootComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Vident::ViewComponent::RootComponent
- Includes:
- RootComponent
- Defined in:
- lib/vident/view_component/root_component.rb
Constant Summary collapse
- SELF_CLOSING_TAGS =
Set[:area, :base, :br, :col, :embed, :hr, :img, :input, :link, :meta, :param, :source, :track, :wbr].freeze
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/vident/view_component/root_component.rb', line 18 def call # Generate outer tag options and render tag_type = content_tag_type child_content = content # Evaluate before generating the outer tag options to ensure DSL methods are executed = if SELF_CLOSING_TAGS.include?(tag_type) view_context.tag(tag_type, ) else view_context.content_tag(tag_type, child_content, ) end end |
#target_tag(tag_name, targets, **options, &block) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/vident/view_component/root_component.rb', line 10 def target_tag(tag_name, targets, **, &block) parsed = parse_targets(Array.wrap(targets)) [:data] ||= {} [:data].merge!(build_target_data_attributes(parsed)) content = view_context.capture(&block) if block view_context.content_tag(tag_name, content, ) end |