Class: Vident::RootComponent::UsingViewComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Vident::RootComponent::UsingViewComponent
- Includes:
- Base, UsingBetterHTML
- Defined in:
- lib/vident/root_component/using_view_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
Methods included from UsingBetterHTML
#as_targets, #with_actions, #with_controllers
Methods included from Base
#action, #action_data_attribute, #as_targets, #initialize, #named_classes, #target, #target_data_attribute, #with_actions, #with_controllers
Instance Method Details
#call ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/vident/root_component/using_view_component.rb', line 24 def call # Generate outer tag options and render tag_type = content_tag_type = if SELF_CLOSING_TAGS.include?(tag_type) view_context.tag(tag_type, ) else view_context.content_tag(tag_type, content, ) end end |
#target_tag(tag_name, targets, **options, &block) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/vident/root_component/using_view_component.rb', line 16 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 |