Module: Vident::RootComponent::UsingBetterHTML
- Included in:
- UsingPhlexHTML, UsingViewComponent
- Defined in:
- lib/vident/root_component/using_better_html.rb
Instance Method Summary collapse
-
#as_targets(*targets) ⇒ Object
(also: #as_target)
Return the HTML
data-targetattribute for the given targets. -
#with_actions(*actions_to_set) ⇒ Object
(also: #with_action)
Return the HTML
data-actionattribute for the given actions. -
#with_controllers(*controllers_to_set) ⇒ Object
Return the HTML
data-controllerattribute for the given controllers.
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 |