You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

21 lines
775 B

class ApplicationController < ActionController::Base
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
allow_browser versions: :modern
def render_stream(notice: nil, alert: nil, &)
flash.now[:notice] = notice if notice
flash.now[:alert] = alert if alert
streams = []
streams << turbo_stream.replace(:flash, partial: 'layouts/components/flash') if flash.any?
# TODO: turbo_stream_elements which stores any append, prepend, replace, update, remove, before, after or refresh actions
if block_given?
yields = yield(turbo_stream)
if yields.is_a? Array
streams += yields
else
streams << yields
end
end
render turbo_stream: streams
end
end