Class: LiveComponent::TagBuilder
- Inherits:
-
Object
- Object
- LiveComponent::TagBuilder
- Defined in:
- lib/live_component/tag_builder.rb
Instance Method Summary collapse
-
#initialize(controller) ⇒ TagBuilder
constructor
A new instance of TagBuilder.
- #rerender(**kwargs, &block) ⇒ Object
Constructor Details
#initialize(controller) ⇒ TagBuilder
Returns a new instance of TagBuilder.
5 6 7 |
# File 'lib/live_component/tag_builder.rb', line 5 def initialize(controller) @controller = controller end |
Instance Method Details
#rerender(**kwargs, &block) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/live_component/tag_builder.rb', line 9 def rerender(**kwargs, &block) state = JSON.parse(@controller.params[:__lc_rerender_state]) id = @controller.params[:__lc_rerender_id] state["props"]["__lc_attributes"] = { "data-id" => id } component = LiveComponent::RenderComponent.new(state, [], kwargs) # We have to render a turbo stream so Turbo doesn't append this to the <html> tag @controller.turbo_stream.update(:this_id_shouldnt_exist, @controller.render(component, &block)) end |