Class: TurboPower::RenderHelper

Inherits:
Object
  • Object
show all
Extended by:
ActionView::Helpers::TagHelper, StreamHelper
Defined in:
lib/turbo_power/render_helper.rb

Class Method Summary collapse

Methods included from StreamHelper

add_css_class, clear_local_storage, clear_session_storage, clear_storage, console_log, console_table, custom_action, custom_action_all, dispatch_event, graft, history_back, history_forward, history_go, inner_html, insert_adjacent_html, insert_adjacent_text, morph, notification, outer_html, push_state, redirect_to, reload, remove_attribute, remove_css_class, remove_local_storage_item, remove_session_storage_item, remove_storage_item, replace_css_class, replace_state, reset_form, scroll_into_view, set_attribute, set_cookie, set_cookie_item, set_dataset_attribute, set_focus, set_local_storage_item, set_meta, set_property, set_session_storage_item, set_storage_item, set_style, set_styles, set_title, set_value, text_content, toggle_css_class, turbo_clear_cache, turbo_frame_reload, turbo_frame_set_src, turbo_progress_bar_hide, turbo_progress_bar_set_value, turbo_progress_bar_show

Class Method Details

.turbo_stream_action_tag(action, target: nil, targets: nil, template: nil, **attributes) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/turbo_power/render_helper.rb', line 6

def self.turbo_stream_action_tag(action, target: nil, targets: nil, template: nil, **attributes)
  template = action.to_sym.in?(%i[ remove refresh ]) ? "" : tag.template(template.to_s.html_safe)

  if target = convert_to_turbo_stream_dom_id(target)
    tag.turbo_stream(template, **attributes, action: action, target: target)
  elsif targets = convert_to_turbo_stream_dom_id(targets, include_selector: true)
    tag.turbo_stream(template, **attributes, action: action, targets: targets)
  else
    tag.turbo_stream(template, **attributes, action: action)
  end
end