Module: Vident::BetterHtml::RootComponent
- Defined in:
- lib/vident/better_html/root_component.rb
Instance Method Summary collapse
-
#as_targets(*targets) ⇒ Object
(also: #as_target)
Return the HTML ‘data-target` attribute for the given targets.
-
#with_actions(*actions_to_set) ⇒ Object
(also: #with_action)
Return the HTML ‘data-action` attribute for the given actions.
-
#with_controllers(*controllers_to_set) ⇒ Object
Return the HTML ‘data-controller` attribute 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
15 16 17 18 |
# File 'lib/vident/better_html/root_component.rb', line 15 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
22 23 24 25 |
# File 'lib/vident/better_html/root_component.rb', line 22 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
10 11 12 |
# File 'lib/vident/better_html/root_component.rb', line 10 def with_controllers(*controllers_to_set) helpers.html_attributes("data-controller" => controller_list(controllers_to_set)&.html_safe) end |