Sha256: af30b638f0df0a2133a15b93353d86602dd173b6096e0e4c1758fc63c7809d9d
Contents?: true
Size: 949 Bytes
Versions: 1
Compression:
Stored size: 949 Bytes
Contents
# frozen_string_literal: true module StimulusReflex class PageBroadcaster < Broadcaster def broadcast(selectors, data) reflex.controller.process reflex.params[:action] page_html = reflex.controller.response.body return unless page_html.present? document = Nokogiri::HTML.parse(page_html) selectors = selectors.select { |s| document.css(s).present? } selectors.each do |selector| operations << [selector, :morph] html = document.css(selector).inner_html cable_ready[stream_name].morph( selector: selector, html: html, children_only: true, permanent_attribute_name: permanent_attribute_name, stimulus_reflex: data.merge({ morph: to_sym }) ) end cable_ready.broadcast end def to_sym :page end def page? true end def to_s "Page" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stimulus_reflex-3.4.0.pre5 | lib/stimulus_reflex/broadcasters/page_broadcaster.rb |