I had a quick question about rendering a ViewComponent (or something that responds to render_in) using the Turbo::Streams::TagBuilder helper. From what I can tell, this should be valid code:
respond_to do |format|
render turbo_stream: turbo_stream.prepend(:add_new_user, template: NotificationComponent.new(type: :warning, content: "Email in use"))
From my understanding, this should return the NotificationComponent’s markup from render_in as the the content of <template>. Instead I’m seeing the class inspect output when this is prepended: <notificationcomponent:0x00007fe5eca77d60></notificationcomponent:0x00007fe5eca77d60>.
I’ve tried different keywords and for now have settled on creating a partial that renders this Component and using that. My question is am I missing something obvious here that allows you to render a component directly, or is there room to add a new component rendering keyword that can support this behavior in turbo-rails?
Probably so, I’m new to both ViewComponents and Turbo ( obviously ). I was thinking that, since frames lend themselves to partial content by design, it might be cool to have a more streamlined API for rendering a component. I’m using the inline approach now and it’s working for my purposes.