Module: Vident::RootComponent::UsingBetterHTML

Included in:
UsingPhlexHTML, UsingViewComponent
Defined in:
lib/vident/root_component/using_better_html.rb

Instance Method Summary collapse

Instance Method Details

#as_targets(*targets) ⇒ Object Also known as: as_target

Return the HTML data-target attribute for the given targets



16
17
18
19
# File 'lib/vident/root_component/using_better_html.rb', line 16

def as_targets(*targets)
  attrs = build_target_data_attributes(parse_targets(targets))
  helpers.html_attributes(attrs.transform_keys! { |k| "data-#{k}" })
end

#with_actions(*actions_to_set) ⇒ Object Also known as: with_action

Return the HTML data-action attribute for the given actions



23
24
25
26
# File 'lib/vident/root_component/using_better_html.rb', line 23

def with_actions(*actions_to_set)
  actions_str = action_list(actions_to_set)
  actions_str.present? ? helpers.html_attributes("data-action" => actions_str) : nil
end

#with_controllers(*controllers_to_set) ⇒ Object

Return the HTML data-controller attribute for the given controllers



11
12
13
# File 'lib/vident/root_component/using_better_html.rb', line 11

def with_controllers(*controllers_to_set)
  helpers.html_attributes("data-controller" => controller_list(controllers_to_set)&.html_safe)
end