Module: Lesli::TurboHelper
- Defined in:
- app/helpers/lesli/turbo_helper.rb
Instance Method Summary collapse
- #render_form_stream(partial_path, locals = {}) ⇒ Object
- #stream_notification_success(message) ⇒ Object
- #turbo_link_to(body, url, html_options = {}) ⇒ Object
Instance Method Details
#render_form_stream(partial_path, locals = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/helpers/lesli/turbo_helper.rb', line 58 def render_form_stream(partial_path, locals = {}) # Detect the current engine's namespace engine_name = controller.class.module_parent_name.underscore # Ensure the correct namespace is applied (only if not already present) partial_path = "#{engine_name}/#{partial_path}" # Convert the partial path to a valid DOM ID partial_id = partial_path.tr("/", "-").tr("_", "-") # Renders the stream to update the partial turbo_stream.replace(partial_id) do render(partial_path, locals) end end |
#stream_notification_success(message) ⇒ Object
51 52 53 54 55 56 |
# File 'app/helpers/lesli/turbo_helper.rb', line 51 def stream_notification_success() success() turbo_stream.replace("application-lesli-notifications") do render("lesli/partials/application-lesli-notifications") end end |
#turbo_link_to(body, url, html_options = {}) ⇒ Object
36 37 38 |
# File 'app/helpers/lesli/turbo_helper.rb', line 36 def turbo_link_to body, url, = {} link_to(body, url, class: "link", data: { turbo_frame: '_top' }) end |